I am working on rename functionality for blob,as there is no way to rename blobs I am deleting the blob and creating new file with rename.however due to asyn nature sometimes blob is not getting delted and new blob gets created so i want to write async/await for both blobservices. How to achieve that as without callback it gives error?
module.rename=function(req,rez){
return new Promise((resolve, reject) => {
let results = await genericHandler.getUserSubscMapping();
if (contentType != 'folder') {
blobService.startCopyBlob(storageuri, containerName, blobName, err => {
if (err) {
return res.status(500).send("Error while renaming the blob");
} else {
blobService.deleteBlobIfExists(containerName, oldFilePath, (err) => {
if (err) {
console.log(err);
reject(err)
return res.status(400).send(err);
} else {
res.status(200).json({
status: 'success'
});
}
});
}
});
}
});
}
Tried code:
let res1 = await blobService.startCopyBlob(storageuri, containerName, blobName);//////error : Required argument callback for function startCopyBlob is not defined
old code where I was using call back is working fine however I want to fetch this result first then perform next oprations , searched regarding async/await on blob service but does not seem to find any article.