mattdavis90
mattdavis90

Reputation: 83

Google Cloud Storage seeking within files

The Google App Engine website (https://developers.google.com/appengine/docs/python/googlestorage/functions#seek) hints at being able to seek within files on Google Cloud Storage. However, on the Google Cloud Storage API pages there is no sign of being able to seek.

I wondered if it is possible to seek within files stored on Google Cloud Storage using the API, from non Google App Engine servers.

Upvotes: 4

Views: 2304

Answers (1)

fejta
fejta

Reputation: 3121

Use the Range header to do this.

The following will get six bytes 10, 11, 12, 13, 14 and 15.

curl -v -H "Range: bytes=10-15" http://storage.googleapis.com/pub/gsutil.tar.gz

> GET /pub/gsutil.tar.gz HTTP/1.1
> Host: storage.googleapis.com
> Accept: */*
> Range: bytes=10-15
>
HTTP/1.1 206 Partial Content
< Content-Range: bytes 10-15/1092318
< Content-Length: 6
{ [data not shown]

Bytes start at 0 to (length - 1). So a 5 byte file contains bytes 0, 1, 2, 3 and 4.

Upvotes: 12

Related Questions