使用AzureBlob时只有一次下载百分比
async function getBackupTemplate(shipKey, historyLogBlobDirectory, reportDataBlobDirectory) {
const historyLogStreamPath = `${window.remote.app.getPath('userData')}/backupStream1.txt`;
const reportDataStreamPath = `${window.remote.app.getPath('userData')}/backupStream2.txt`;
const historyLog = await new Promise((resolve, reject) => {
const stream = fs.createWriteStream(historyLogStreamPath);
let historySummary = window.blobService.getBlobToStream(window.containerName, historyLogBlobDirectory, stream, async (err, text) => {
console.log(historyLogStreamPath)
console.log('historySummary1', historySummary)
if (err) {
if (err.statusCode === 403) {
azureCustomService.setRequestDateHeaderFromAzureServerTimeStamp(err.message);
await azureCustomService.communicateAzureWithCustomHeader('GET', window.containerName, historyLogBlobDirectory);
try {
azureCustomService.streamParsingToJSON(historyLogStreamPath, (err, data) => {
resolve(JSON.parse(data));
});
} catch (e) {
reject(e);
}
}
} else {
console.log('comp history', text)
azureCustomService.streamParsingToJSON(historyLogStreamPath, (err, data) => {
resolve(JSON.parse(data));
});
}
});
console.log('historySummary2', historySummary)
historySummary.on('progress', function() {
var percentComplete = historySummary.getCompletePercent(2);
var totalSize = historySummary.getTotalSize(true);
console.log('Upload Complete3' + percentComplete);
console.log('total: ' + totalSize);
});
});
----结果-----
上传完整3(%):100.00
总计:4.61KB
我想获得下载Progress实时,
但是连接完成后仅一次。
我该怎么做?
async function getBackupTemplate(shipKey, historyLogBlobDirectory, reportDataBlobDirectory) {
const historyLogStreamPath = `${window.remote.app.getPath('userData')}/backupStream1.txt`;
const reportDataStreamPath = `${window.remote.app.getPath('userData')}/backupStream2.txt`;
const historyLog = await new Promise((resolve, reject) => {
const stream = fs.createWriteStream(historyLogStreamPath);
let historySummary = window.blobService.getBlobToStream(window.containerName, historyLogBlobDirectory, stream, async (err, text) => {
console.log(historyLogStreamPath)
console.log('historySummary1', historySummary)
if (err) {
if (err.statusCode === 403) {
azureCustomService.setRequestDateHeaderFromAzureServerTimeStamp(err.message);
await azureCustomService.communicateAzureWithCustomHeader('GET', window.containerName, historyLogBlobDirectory);
try {
azureCustomService.streamParsingToJSON(historyLogStreamPath, (err, data) => {
resolve(JSON.parse(data));
});
} catch (e) {
reject(e);
}
}
} else {
console.log('comp history', text)
azureCustomService.streamParsingToJSON(historyLogStreamPath, (err, data) => {
resolve(JSON.parse(data));
});
}
});
console.log('historySummary2', historySummary)
historySummary.on('progress', function() {
var percentComplete = historySummary.getCompletePercent(2);
var totalSize = historySummary.getTotalSize(true);
console.log('Upload Complete3' + percentComplete);
console.log('total: ' + totalSize);
});
});
----result----
Upload Complete3 (%): 100.00
total: 4.61KB
I want get download progress realtime
but it coming only one time after connection complete.
How can I make ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
•
存储客户端的默认限制为单个块上传
的32 MB最大尺寸。当块blob上传大于'singleblobuploploploploadthresholdinbytes'属性中的值时,存储客户端将文件分解为最大允许大小的块并尝试将其上传
。由于您试图上传的块斑点大小可能大于32 MB,因此它会引发异常并将文件分解为允许的较小块,因此上传进度栏不会跟踪上传的斑点的进度,直到上传到这一点并陷入困境。因此,我建议您可以尝试设置'singleblobuploploadthresholdinbytes'属性或捕获'网络软件包'当您调用'uploadfrombytearray'方法时详细错误。有关更多详细信息,请参阅下面的链接: -
将Azure Blob块上传限制从32 MB
•也请参考以下社区线程,该线程建议使用a <<强>在功能中注册的功能中的公式,以计算使用以下公式: -
azure储存blob下载进度指标
•
Storage clients have a default limit of 32 MB maximum size for a single block upload
. When a block blob upload is larger than the value in ‘SingleBlobUploadThresholdInBytes’ property,storage clients break the file into blocks of maximum allowed size and try to upload it
. Since the block blob size that you are trying to upload might be greater than 32 MB, it throws an exception and breaks the file into allowed smaller chunks due to which the upload progress bar doesn’t track the progress of blobs uploaded until that point and gets stuck. Thus, I would suggest you could try to set the ‘SingleBlobUploadThresholdInBytes’ property or capture the ‘Network Package’ when you invoke the ‘UploadFromByteArray’ method to find the detailed error.For more details, kindly refer to the link below: -
Increase Azure blob block upload limit from 32 MB
• Also, kindly refer to the below community thread which suggests a workaround by using a formula in the function that is registered with the progress class to calculate the total file size uploaded by using the below formula: -
Azure Storage Blob Download Progress Indicator