Ahmer Khan
Ahmer Khan

Reputation: 767

How to add Authorization header in azure blob storage?

I want to upload video to azure blob storage using its JavaScript client library. I have the SAS token from the API and I have created an instance for blob service like this:

var blobUri = 'https://<account>.blob.core.windows.net/';
vm.sasTOken = "?sv=2016-05-31&sr=c&sig=abcdefghhi&st=2017-10-12T07%3A10%3A05Z&se=2017-10-12T11%3A10%3A05Z&sp=rl"
var blobService = AzureStorage.createBlobServiceWithSas(blobUri, vm.sasToken);

I have tried to upload a video with this service

speedSummary = blobService.createBlockBlobFromBrowserFile('containerName', vm.file.name, vm.file, { blockSize: customBlockSize}, function (error, result, response) {
   if (error) {
      console.log(error);
    } else {
      console.log('success');
    }
  });

I don't know where to pass the Authorization Headers that why its giving me error in console.

403 (Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.)

Upvotes: 2

Views: 2783

Answers (1)

Aaron Chen
Aaron Chen

Reputation: 9940

One more thing:

The start and expiry date/time in the SAS token should be UTC time, not local time.

Please renew the SAS token and ensure these values are not out of the valid range of date/time in UTC.

Upvotes: 3

Related Questions