Azure / azure-storage-cpplite

Lite version of C++ Client Library for Microsoft Azure Storage
MIT License
25 stars 44 forks source link

How to Set Blob Content-Type #107

Open dczaretsky opened 3 years ago

dczaretsky commented 3 years ago

When uploading to azure blob an image via stream, it always sets the content type to "application/octet-stream". How do you change the content type when it is uploaded?

I've tried setting the meta content as follows:

vector<pair<string,string>> metadata(1, std::make_pair("Content-Type", "image/jpg"));
client.upload_block_blob_from_stream(AZURE_BLOB_CONTAINER, filename, istream, metadata);

This only adds meta content, but doesn't change the blob properties. I've also tried to directly change the curl request headers:

auto bc = std::make_shared<blob_client>(account, 16);
std::shared_ptr<azure::storage_lite::http_base> http_request = bc->client()->get_handle();
http_request->add_header("Content-Type", "image/jpg");
vector<pair<string,string>> metadata;
bc->upload_block_blob_from_stream(AZURE_BLOB_CONTAINER, filename, istream, metadata);

Any help would be greatly appreciated.

Jinming-Hu commented 3 years ago

@dczaretsky cpplite doesn't support this feature. I recommend you use our Track2 cpp sdk. https://github.com/Azure/azure-sdk-for-cpp/tree/master/sdk/storage