Skip to content

Commit

Permalink
Fix setting ContentRange to inclusive positions
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Nov 13, 2015
1 parent 6890fa1 commit cf777fc
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.primitives.Ints;
import com.google.gcloud.storage.StorageException;
import com.google.gcloud.storage.StorageOptions;

Expand Down Expand Up @@ -415,7 +416,7 @@ public byte[] read(StorageObject from, Map<Option, ?> options, long position, in
.setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options))
.setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options));
MediaHttpDownloader downloader = req.getMediaHttpDownloader();
downloader.setContentRange(position, (int) position + bytes);
downloader.setContentRange(position, Ints.checkedCast(position + bytes - 1));
downloader.setDirectDownloadEnabled(true);
ByteArrayOutputStream output = new ByteArrayOutputStream();
req.executeMediaAndDownloadTo(output);
Expand Down

0 comments on commit cf777fc

Please sign in to comment.