使用AzureBlob时只有一次下载百分比

发布于 2025-02-10 06:53:25 字数 2091 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘦怹 2025-02-17 06:53:25

存储客户端的默认限制为单个块上传的32 MB最大尺寸。当块blob上传大于'singleblobuploploploploadthresholdinbytes'属性中的值时,存储客户端将文件分解为最大允许大小的块并尝试将其上传。由于您试图上传的块斑点大小可能大于32 MB,因此它会引发异常并将文件分解为允许的较小块,因此上传进度栏不会跟踪上传的斑点的进度,直到上传到这一点并陷入困境。因此,我建议您可以尝试设置'singleblobuploploadthresholdinbytes'属性捕获'网络软件包'当您调用'uploadfrombytearray'方法时详细错误。

有关更多详细信息,请参阅下面的链接: -

将Azure Blob块上传限制从32 MB

•也请参考以下社区线程,该线程建议使用a <<强>在功能中注册的功能中的公式,以计算使用以下公式: -

  (bytesUploadedSoFar/totalFileSizeInBytes)*100

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: -

  (bytesUploadedSoFar/totalFileSizeInBytes)*100

Azure Storage Blob Download Progress Indicator

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文