2
votes

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.)

1
Can you share what your SAS token looks like? More than likely you have an invalid SAS token. - Gaurav Mantri
Its like this ?sv=2016-05-31&sr=c&sig=rtPk88o2Y%2BpgFSk6JlJX8dPVUfx%2FhSfXkhQEDgyAn%2F8%3D&st=2017-10-12T06%3A55%3A09Z&se=2017-10-12T10%3A55%3A09Z&sp=rl - Ahmer Khan
Thanks! In order for uploading file in a blob container, the SAS token should have Write permission. From the SAS token you shared, it seems you only included Read and List permission. Please create a SAS token with Write permission and try again. - Gaurav Mantri
@GauravMantri The write permission is already there in the token i have checked. - Ahmer Khan
Can you please edit your question and include the following things: 1) value for blobUri (you can replace actual account name with a dummy string 2) value for containerName you are passing in createBlockBlobFromBrowserFile function and 3) value for vm variable that you're getting back from your API. You can replace the actual signature value in your SAS token with a dummy string. - Gaurav Mantri

1 Answers

3
votes

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.