You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
com.google.cloud.storage.Blob has download method, but it takes OutputSteam, but instead it should provide access to InputStream, which can open more options on the data.
Hi @nanda-kumar-office1, Can you expand on what types of things you are hoping to accomplish via using an InputStream directly?
Currently downloadTo transparently takes care of retrying a request that may have been interrupted, decompressing if there was any transport compression as well as moving the bytes to the provided OutputStream with minimal copying.
Thank you Ben for the response.
downloadTo is perfect for Desktop kind of app, but on server side programming, we may have to set few headers before streaming the file content to user. Also, it may not be a good practice to pass servlet response handler all the way to the backend layer.
Feel free if you have more question, I can get specific examples based on api that I had been working across other vendor apis too.
Unfortunately we haven't been able to get around to implementing this yet as we've ran into some potential issues needing to manage the streams that are passed out from the underlying rpc systems.
For the interim, your best bet is to do something like the following where you leverage our resumable download reader:
Glad to hear you were able to figure out something that worked for you. One thing of note however, if you use the reader adapter I mentioned above you will receive our automatic retry for downloading of individual chunks. So if you have medium~ish size blobs (more than say 5mb), this might help in the reliability perception for your app.
Apologies on the very late reply to this issue. Recently we've been able to clean up a large portion of the internal middleware of the client for the read path of objects. This allows storage.reader (and blob.reader) to provide bandwidth competitive with downloadTo[1] and providing transparent automatic retries - something downloadTo can't do. As such, the recommended path moving forward is to leverage the code shared in #928 (comment).
Activity
BenWhitehead commentedon Jul 27, 2021
Hi @nanda-kumar-office1, Can you expand on what types of things you are hoping to accomplish via using an
InputStreamdirectly?Currently
downloadTotransparently takes care of retrying a request that may have been interrupted, decompressing if there was any transport compression as well as moving the bytes to the providedOutputStreamwith minimal copying.nanda-kumar-office1 commentedon Jul 28, 2021
Thank you Ben for the response.
downloadTo is perfect for Desktop kind of app, but on server side programming, we may have to set few headers before streaming the file content to user. Also, it may not be a good practice to pass servlet response handler all the way to the backend layer.
Feel free if you have more question, I can get specific examples based on api that I had been working across other vendor apis too.
BenWhitehead commentedon Oct 5, 2021
Unfortunately we haven't been able to get around to implementing this yet as we've ran into some potential issues needing to manage the streams that are passed out from the underlying rpc systems.
For the interim, your best bet is to do something like the following where you leverage our resumable download reader:
nanda-kumar-office1 commentedon Oct 6, 2021
Thank you Ben,
During the course, I used the below workaround code that worked for us.
BlobInfo blobInfo = BlobInfo.newBuilder(BlobId.of(bucketName, filePath)).build();
URL url = storage.signUrl(blobInfo,5,TimeUnit.MINUTES,SignUrlOption.withV4Signature());
InputSteam in = url.openStream()
BenWhitehead commentedon Oct 6, 2021
Glad to hear you were able to figure out something that worked for you. One thing of note however, if you use the reader adapter I mentioned above you will receive our automatic retry for downloading of individual chunks. So if you have medium~ish size blobs (more than say 5mb), this might help in the reliability perception for your app.
nanda-kumar-office1 commentedon Oct 6, 2021
Sure Ben, let me try it and update you.
Thanks,
BenWhitehead commentedon Feb 1, 2023
Apologies on the very late reply to this issue. Recently we've been able to clean up a large portion of the internal middleware of the client for the read path of objects. This allows storage.reader (and blob.reader) to provide bandwidth competitive with
downloadTo[1] and providing transparent automatic retries - something downloadTo can't do. As such, the recommended path moving forward is to leverage the code shared in #928 (comment).[1] #1799