Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 611
mattdavis90 Avatar asked Dec 16 '22 15:12

mattdavis90


1 Answers

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.

like image 174
fejta Avatar answered Dec 25 '22 03:12

fejta