ThouCheese / cloud-storage-rs

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

Read + Seek from object? #112

Closed curoli closed 2 years ago

curoli commented 2 years ago

Hello,

I need a Read + Seek for a GCS object. Is there a way to get this? Thanks!

Best, Oliver

ThouCheese commented 2 years ago

This is currently not implemented in cloud-storage, however, you can download the contents of a file to a vec and then wrap that in a cursor:

let bytes = Object::download("my_bucket", "path/to/my/file.png").await?;
let cursor = std::io::Cursor::new(bytes);
// now cursor implements Read and Seek