Azure / azure-storage-ruby

Microsoft Azure Storage Library for Ruby
http://azure.github.io/azure-storage-ruby/
82 stars 158 forks source link

Direct upload and `x-ms-blob-type` header #89

Closed dixpac closed 7 years ago

dixpac commented 7 years ago

Hey!

I'm using azure for direct upload from rails app. My controller generates signed_url using Azure::Storage::Core::Auth::SharedAccessSignature#signed_url and returns it as a json response. From my js I then upload file to that signed_url.

Problem: My client side upload works works only if I specify x-ms-blob-type': 'BlockBlob in the header. Can I specify this value on the signer to be appended to the query string instead of manually adding header on the js side

My signer code

signer = Azure::Storage::Core::Auth::SharedAccessSignature.new(storage_account_name, storage_access_key)
signer.signed_uri(URI(base_url), false, permissions: "rw", service: "b", resource: "b", expiry: expires_in).to_s

is something like this possible


signer.signed_uri(URI(base_url), false, permissions: "rw", service: "b", resource: "b", blob_type: "BlockBlob", expiry: expires_in).to_s
yaxia commented 7 years ago

@dixpac Thanks for sharing your idea. We don't support specifying the blob type in the query string for now. The consideration behind it is the query string in Azure Storage REST API works like a filter for a collection of resource or operations. The blob type is a required parameter for PutBlob operation, so we make that a header.

dixpac commented 7 years ago

@yaxia thanks for the response! I've asked this question on azure-sdk-ruby but no one is answering.

What is the difference between this gem and azure-sdk-ruby which one to use for storage?

Also, are you interested for PR adding x-ms-blob-type in the signer instead of headers, reason for this is that we are adding new rails component called activestorage which is going to ship with azure,gcs and s3 in the box and this change will make our life easier. Please feel free to look at my WIP implementation of azure-storag

yaxia commented 7 years ago

@dixpac Regarding your question:

What is the difference between this gem and azure-sdk-ruby which one to use for storage?

The differences are:

  1. azure_mgmt_storage is for storage account management. You can create, delete, list and modify your storage accounts and azure-storage is for data (blob/table/queue/file) management under a storage account.
  2. Comparing to the asm branch of azure-sdk-ruby, azure-storage has more client side improvements and actively maintains the feature parity with those on the service. Please refer to #5 for details.

It is exciting to know you are bringing Azure storage to rails and I am interested to send PR. I will look into your implementation first and will keep you updated. Thanks.