Hello all,
I am trying to download the file stored in azure blob to local machine using javascript.
I am using this url -
Url = https://storageaccount.blob.core.windows.net/containerName/blobName?SASToken
I am using javascript client library, which include function "blobService.getUrl()".
But its not providing correct url, i am getting authorization header not formed correctly error.
I don't want to use azureblob Node.js library as i have to install bundler.
I used below code
function getUrlOfAttachmentFileFromBlob(new_fileurl,new_fileName) {
var blobUri = 'https://' + 'Storage_Account_Name' + '.blob.core.windows.net';
var containerName = 'trial';
var sas_token = 'sastoken' ;
var blobService = AzureStorage.Blob.createBlobServiceWithSas(blobUri, sas_token);
var downloadLink = https://storageaccount.blob.core.windows.net/containerName/blobName?SASToken;
if (downloadLink != null)
{
downloadURI(downloadLink, new_fileName);
}
}
function downloadURI(uri, name)
{
var link = document.createElement("a");
link.setAttribute('download', name);
link.href = uri;
document.body.appendChild(link);
link.click();
}
With this code, I can see the content of the file in browser.
But i dont want to see the content. I want file to be downloaded to my local machine.
I tried using azure 'get blob' rest api. It also shows the content of the file.
How can i download the file?