Reputation: 77
How to iterate Amazon S3 file partially?
In the code below
GetObjectRequest rangeObjectRequest = new GetObjectRequest(
bucket, key);
rangeObjectRequest.setRange(0, 10);
S3Object objectPortion = amazonS3Client.getObject(rangeObjectRequest);
As per the documentation, I can only enter values from 0 to 9.
/* The first byte in an object has position 0; as an example, the first ten bytes of an object can be downloaded by specifying a range of 0 to 9.*/
http://docs.aws.amazon.com/AmazonS3/latest/dev/RetrievingObjectUsingJava.html
Upvotes: 1
Views: 373
Reputation: 179084
You're overlooking the significance of the phrase "as an example".
If you want to read the first 10 bytes, you start at offset 0 and stop after offset 9. If you want the 101st through 200th byte, the values would be 100, 199 (the first byte is offset 0).
Any values < the total number of bytes in the object are valid.
Upvotes: 2