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
I can use memmap to effectively stream a large file when calling create_object(), but when calling get() it will always return a Vec<u8> result. I see there are commented out "writer" and "reader" functions, so I'm filing this request just to track the need for this feature. For my use case, I'm always going to be dealing with files that are 64mb or larger, so streaming would be good.
P.S. The google_storage1 crate defines a ReadSeek trait that is used for uploading files. For download, I think they rely on hyper, enabling std::io::copy() directly to a file.
The text was updated successfully, but these errors were encountered:
I agree that the ability to read and write GCS objects in a streaming fashion is definitely valuable.
The one thing that kind of blocked the implementation was that it was unclear what the API for it should be.
I am currently considering the following API:
implObject{// `ObjectReader` would implement `futures_io::AsyncRead`pubasyncfnreader(&mutself) -> Result<ObjectReader,Error>{// ...}// `ObjectWriter` would implement `futures_io::AsyncWrite`pubasyncfnwriter(&mutself,mime_type:implAsRef<str>) -> Result<ObjectWriter,Error>{// ...}}
But other crates sometime go for an API that resembles the following:
implObject{// Asynchronously streams the bytes from the GCS object into the provided writer.pubasyncfnstreaming_get<W:AsyncWrite>(&mutself,writer:W) -> Result<(),Error>{// ...}// Asynchronously streams the bytes from the provided reader into the GCS object.pubasyncfnstreaming_put<R:AsyncRead>(&mutself,mime_type:implAsRef<str>,reader:R) -> Result<(),Error>{// ...}}
I was more inclined to implement the first design rather than the second one because the second one moves the iteration process away from your control and therefore makes it harder to just iterate over the bytes manually, without needing some kind of IO AsyncRead/AsyncWrite in-memory pipe, like the one from sluice.
But I suspect that even the first design might require this kind of in-memory IO pipe to implement the writer method.
I try to implement the storage API right now into the following project of mine https://github.com/Roba1993/stow
Maybe you can get some idea on how to solve it there. I went with a AsyncRead for both file get and put, which works quiete nicely.
I can use
memmap
to effectively stream a large file when callingcreate_object()
, but when callingget()
it will always return aVec<u8>
result. I see there are commented out "writer" and "reader" functions, so I'm filing this request just to track the need for this feature. For my use case, I'm always going to be dealing with files that are 64mb or larger, so streaming would be good.P.S. The google_storage1 crate defines a
ReadSeek
trait that is used for uploading files. For download, I think they rely on hyper, enablingstd::io::copy()
directly to a file.The text was updated successfully, but these errors were encountered: