Skip to content

Provide an efficient way to download the latest version of an object #1158

@n12c

Description

@n12c

Blob#downloadTo is the library's efficient method for downloading blob data to an arbitrary sink. It is efficient because, unlike Storage#reader, it downloads the blob in one request as opposed to many, and because it performs much less copying. This results in significantly higher throughput and significantly lower memory pressure.

The sequence of Storage#get followed by Blob#downloadTo, which is required to use this API, is prone to races. This is due to the way that the blob's generation, as it existed at Storage#get, is unconditionally encoded into the HTTP request generated by Blob#downloadTo. If the bucket does not use versioning, the generation may change between Storage#get and Blob#downloadTo, leading to a 404.

With Storage#reader we can avoid this problem by not specifying the generation, for example using reader(String, String), which will read the latest generation. No such workaround is possible with Blob#downloadTo, meaning that a usage of Blob#downloadTo has to have a fallback that catches the 404 and retries using Storage#reader with the generation unspecified. This is inefficient and inelegant, and should not be required.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/java-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions