TypeError cannot set property 'size of' undefined in typeScript Azure blob upload

Viewed 203

i'm trying to upload the file from the local path to azure blob storage. below is the code. While uploading i'm getting error like TypeError cannot set property 'size of' undefined .

The connection to Azure Blob storage got succeeded with SAS token(observed from Console), but getting error internally to get the size of the file. Could you please suggest any here to resolve this issue. Note: With StorageSharedKeyCredential the connection to Azure itself not getting succeeded, showing storage shared key credentials is not a constructor.

enter image description here

const {
    StorageSharedKeyCredential,
    BlobServiceClient
    } = require('@azure/storage-blob');
const path = require("path");
const localFilePath = "G:/test/download2.jpg";

const STORAGE_ACCOUNT_NAME = "***********";
const containerName = "container1";
const sas = "******************";

const blobServiceClient = new AzureAPI.BlobServiceClient(`https://${STORAGE_ACCOUNT_NAME}.blob.core.windows.net${sas}`);
const containerClient = blobServiceClient.getContainerClient(containerName);

const fileName = path.basename(localFilePath);
const blobClient = containerClient.getBlobClient(fileName);
const blockBlobClient = blobClient.getBlockBlobClient();
blockBlobClient.uploadFile(localFilePath)

;

0 Answers
Related