-2

I am accessing Azure Media Rest API using javascript (angular js), I followed the Microsoft documentation(https://learn.microsoft.com/en-us/azure/media-services/media-services-rest-get-started) through which I was able to generate the token, connect to media services, create the access token and the locator. But after this step, I am facing a problem in uploading a file into a blob storage container. Is there any way to perform uploading of a file via client side using Angular js or javascript?

while making a request:- PUT https:/storageaccountname.blob.core.windows.net/assetcontainer/filename?sas token HTTP/1.1 Host: storageaccount.blob.core.windows.net Connection: keep-alive Content-Length: 223 x-ms-blob-type: BlockBlob Origin: http://localhost Authorization : SharedKey accountnamw: access key Content-Type: video/mp4 Accept: application/json, x-ms-version: 2011-08-18

This gives a response :- HTTP/1.1 400 Authentication information is not given in the correct format. Check the value of Authorization header. Content-Length: 297 Content-Type: application/xml x-ms-request-id: e6b8eeaa-0001-003e-4403-6958b9000000 Access-Control-Allow-Origin:localhost Access-Control-Allow-Credentials: true Date: Sat, 07 Jan 2017 16:34:38 GMT

On trying to remove authorization header and date header from the request, the response we receive is a 404 error: resource does not exist. I am looking for a proper solution to upload file to the blob storage container, kindly help me in resolving this issue .

Thank you..

2 Answers2

0

Since uploading is not something that is handled by the Media Services API itself, you would need to look for examples of using the Azure Storage APIs to upload into a Block Blob via a SAS URL.

Since you have a writable Locator (SAS URL) already, you now need to write to the block blob.

I've seen some examples of doing this out there on the web from client side Angular code. For example - https://blogs.msdn.microsoft.com/kaevans/2015/12/18/securely-upload-to-azure-storage-with-angular/

I'll check to see if we have any more examples

johndeu
  • 2,494
  • 1
  • 11
  • 10
  • While making a request which looks like :- – Mohit Nautiyal Jan 07 '17 at 16:48
  • PUT storageaccountname.blob.core.windows.net/asset/… HTTP/1.1 Host: storageaccountname.blob.core.windows.net ,Connection: keep-alive, x-ms-blob-type: BlockBlob, Authorization : SharedKey myaccount: "key" ,Content-Type: video/mp4, Accept: application/json, x-ms-version: 2011-08-18 x-ms-date: Sat, 07 Jan 2017 16:07:36 GMT – Mohit Nautiyal Jan 07 '17 at 16:49
  • response: HTTP/1.1 400 Authentication information is not given in the correct format. Check the value of Authorization header. Content-Length: 297 Content-Type: application/xml Server: Microsoft-HTTPAPI/2.0 x-ms-request-id: -------- Access-Control-Allow-Origin: localhost Access-Control-Allow-Credentials: true Date: Sat, 07 Jan 2017 16:34:38 GMT – Mohit Nautiyal Jan 07 '17 at 16:51
  • And when we remove the Authorization header, date header from the request, the response we receive is 404:the specified resource does not exist. Can you guide me the way to step out of this issue . – Mohit Nautiyal Jan 07 '17 at 16:52
  • Hi,@MohitNautiyal, according your comment timeline, at last you have solved your issue? If you still have any concerns, please let me know. – Gary Liu Jan 09 '17 at 01:40
0

Currently, there is not an existing Azure storage SDK for javascript in client side using. So we can manually generate SAS token URLs fro uploading blobs from client applications.

You can refer to https://learn.microsoft.com/en-us/azure/storage/storage-dotnet-shared-access-signature-part-1 for the detailed guidance.

Also, you can refer this thread Authorization of Azure Storage service REST API as we discussed how to generate SAS token in javascript on client side previous.

Community
  • 1
  • 1
Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • This issue is taking a lot of efforts to clear and still we are facing some or other problem again and again . – Mohit Nautiyal Jan 07 '17 at 16:36
  • PUT https://storageaccountname.blob.core.windows.net/asset/filename?sastoken HTTP/1.1 Host: storageaccountname.blob.core.windows.net Connection: keep-alive x-ms-blob-type: BlockBlob Authorization : SharedKey myaccount: "key" Content-Type: video/mp4 Accept: application/json, x-ms-version: 2011-08-18 x-ms-date: Sat, 07 Jan 2017 16:07:36 GMT.... – Mohit Nautiyal Jan 07 '17 at 16:43
  • response: HTTP/1.1 400 Authentication information is not given in the correct format. Check the value of Authorization header. Content-Length: 297 Content-Type: application/xml Server: Microsoft-HTTPAPI/2.0 x-ms-request-id: -------- Access-Control-Allow-Origin: localhost Access-Control-Allow-Credentials: true Date: Sat, 07 Jan 2017 16:34:38 GMT – Mohit Nautiyal Jan 07 '17 at 16:44
  • And when we remove the Authorization header, date header from the request, the response we receive is 404:the specified resource does not exist. Can you guide me the way to step out of this issue – Mohit Nautiyal Jan 07 '17 at 16:47