I'm using uploadData() method for uploading local file to azure file share.I'm facing issue with onProgress as I'm getting a single progress update i.e. the final update when file finally gets uploaded. Can some guide where I'm going wrong?
await fileClient.uploadData(selectedFile, { rangeSize: 4 * 1024 * 1024, // 4MB range size parallelism: 20, // 20 concurrency onProgress: ev => console.log(ev) });
Azure Files offers fully managed file shares in the cloud that are accessible via the industry standard Server Message Block (SMB) protocol.
I checked some documents and blogs and found that the method is a parallel uploading method and it just sends a single request to Azure Storage server. So if you want to get onProgress executed many times, I suggest you use the method uploadStream. For more information check this parallel uploading methods.
We can achieve Parallel uploading a Readable stream with ShareFileClient.uploadStream() in Node.js runtime as shown below.
await fileClient.uploadStream(fs.createReadStream(localFilePath), fileSize, 4 * 1024 * 1024, 20, {
abortSignal: AbortController.timeout(30 * 60 * 1000), // Abort uploading with timeout in 30mins
onProgress: (ev) => console.log(ev)
});
console.log("uploadStream success");
Also read this FileUploadStreamOptions interface document for more information.