Skip to content

Commit

Permalink
Merge pull request #375 from mziccard/fix-content-range
Browse files Browse the repository at this point in the history
Fix setting ContentRange to inclusive positions
  • Loading branch information
aozarov committed Nov 13, 2015
2 parents b7099e0 + cf777fc commit d039537
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 d039537

Please sign in to comment.