I'm trying to download a byte range from Google Cloud Storage, using their Java SDK.
I can download an entire file like this.
Storage mStorage; // initialized and working
Blob blob = mStorage.get(pBucketName, pSource);
try (ReadChannel reader = mStorage.reader(blob.getBlobId())) {
// read bytes from read channel
}
If I want, I can ReadChannel#seek(long) until I reach a desired starting byte, and download a range from that point, but that seems inefficient (although I don't know exactly what's happening in the implementation.)
Ideally I would like to specify the Range: bytes=start-end header as shown in the Google Cloud Storage REST API, but I can't figure out how to set the header in Java.
How can I specify the byte range in the Java SDK Storage get call, or specify the header, so I can efficiently download the desired byte range?