Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify byte range via query string in Get Object S3 request

I'm familiar with the Range HTTP header; however, the interface I'm using to query S3 (an img element's .src property) doesn't allow me to specify HTTP headers.

Is there a way for me to specify my desired range via a parameter in the query string?

It doesn't seem like there is, but I'm just holding out a shred of hope before I roll my own solution with ajax requests.

like image 739
Coleman S Avatar asked Nov 17 '14 02:11

Coleman S


People also ask

Does S3 support range request?

(Amazon S3 supports Range GET requests, as do many HTTP servers.)

Can you query data from S3 bucket?

With Amazon S3 Select, you can use simple structured query language (SQL) statements to filter the contents of an Amazon S3 object and retrieve just the subset of data that you need.

What is the potential size range for individual objects stored in Amazon S3?

Individual Amazon S3 objects can range in size from a minimum of 0 bytes to a maximum of 5 TB. The largest object that can be uploaded in a single PUT is 5 GB. For objects larger than 100 MB, customers should consider using the Multipart Upload capability.

What is byte range request?

Byte-range requests occur when a client asks the server for only a portion of the requested file. The purpose of this is essentially to conserve bandwidth usage by avoiding the need to download a complete file when all that is required is a small section.


1 Answers

Amazon S3 supports Range GET requests, as do some HTTP servers, for example, Apache and IIS.

How CloudFront Processes Partial Requests for an Object (Range GETs)

I tried to get my S3 object via cURL:

curl -r 0-1024 https://s3.amazonaws.com/mybucket/myobject -o part1
curl -r 1025-  https://s3.amazonaws.com/mybucket/myobject -o part2
cat part1 part2 > myobject

and AWS SDK for JavaScript:

var s3 = new AWS.S3();
var file = require('fs').createWriteStream('part1');
var params = {
    Bucket: 'mybucket',
    Key: 'myobject',
    Range: 'bytes=0-1024'
};
s3.getObject(params).createReadStream().pipe(file);

These two methods work fine for me.

AWS SDK for JavaScript API Reference (getObject)

like image 125
Mike Feng Avatar answered Sep 19 '22 20:09

Mike Feng