ThouCheese / cloud-storage-rs

A crate for uploading files to Google cloud storage, and for generating download urls.
MIT License
124 stars 87 forks source link

Download range of object? #132

Open shelbyd opened 11 months ago

shelbyd commented 11 months ago

I would like the ability to optionally only download a specific range of an Object. GCS supports this in HTTP downloads with a Range header (https://cloud.google.com/storage/docs/xml-api/get-object-download#request_headers), and in their official libraries with ranges as part of the download parameters.

As far as interface, it would be nice to have the range as an argument to ObjectClient::download. Something like:

async fn download(&self, bucket: &str, file_name: &str, range: impl Into<Option<core::ops::RangeInclusive<u64>>>)

That is a breaking change, so we could additionally define a download_range fn. But that increases bloat, assuming you'd also want download_range_sync.

It's possible I could do this myself with download_url, but I don't want to create signed urls unnecessarily. I could also inline the implementation and do everything myself, but then why use a library?