Azure / azure-storage-cpp

Microsoft Azure Storage Client Library for C++
http://azure.github.io/azure-storage-cpp
Apache License 2.0
132 stars 147 forks source link

Choose which part of a blob to download #246

Closed johnBuffer closed 5 years ago

johnBuffer commented 5 years ago

Hello,

I am trying to implement a full streaming FUSE based filesystem (by full streaming I mean no use of disk storage as cache) over Azure Blob storage.

In the documentation I found this method to download a blob:

// Save blob contents to a file.
concurrency::streams::container_buffer<std::vector<uint8_t>> buffer;
concurrency::streams::ostream output_stream(buffer);
blockBlob.download_to_stream(output_stream);

But I am wondering how would it be possible to integrate this into the read function of a filesystem to download only the needed part of the blob ?

Thank you

katmsft commented 5 years ago

Hi,

You can try call azure::storage::blob::open_read instead, it will return an concurrency::streams::istream that can be used to read on demand.

Also, azure::storage::blob::download_range_to_stream can specify the range that gets downloaded to stream.

johnBuffer commented 5 years ago

Thank you very much for your answer ! I will try these two options.

johnBuffer commented 5 years ago

It is exactly what I needed, thank you very much.

katmsft commented 5 years ago

Also, there is a current library implementing fuse with block blob: https://github.com/Azure/azure-storage-fuse The underneath API calling Azure Storage services is using another lightweight version of this SDK that can be found below: https://github.com/Azure/azure-storage-cpplite