Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async uploadFile(path: string, containerName: string, blobName?: string) {
Guard.empty(path, "path");
Guard.empty(containerName, "containerName");
this.checkInitialization();
// Use specified blob name or replace `/` in path with `-`
const name = blobName || path.replace(/^.*[\\\/]/, "-");
this.log(`Uploading file at '${path}' to container '${containerName}' with name '${name}'`)
await uploadFileToBlockBlob(Aborter.none, path, this.getBlockBlobURL(containerName, name));
this.log("Finished uploading blob");
};
async function uploadLocalFile(aborter, containerURL, filePath) {
filePath = path.resolve(filePath);
const fileName = path.basename(filePath);
const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, fileName);
return await uploadFileToBlockBlob(aborter, filePath, blockBlobURL);
}