Last updated on November 21, 2022
const azureStorage = require('azure-storage');
const path = require('path');
const azureStorageConfig = {
accountName: "",
accountKey: "",
blobURL: "",
containerName: ""
};
const downloadBlob = async (blobName, downloadFilePath) => {
return new Promise((resolve, reject) => {
const name = path.basename(blobName);
const blobService = azureStorage.createBlobService(azureStorageConfig.accountName, azureStorageConfig.accountKey);
blobService.getBlobToLocalFile(azureStorageConfig.containerName, blobName, `${downloadFilePath}${name}`, function(error, serverBlob) {
if (error) {
reject(error);
} else {
resolve(downloadFilePath);
}
});
});
};
downloadBlob('images/6350402094004393-11.jpeg','./downloads/');