简体   繁体   English

Amazon S3文件上传进度永远不会达到100%

[英]Amazon S3 File Upload Progress Never Reaches 100%

I am using an Azure Function and the AWS .NET libraries to upload blobs to S3 from a stream. 我正在使用Azure函数和AWS .NET库将blob从流上传到S3。 During this transfer I subscribe to the UploadProgressEvent which receives the bytes transferred and the percent complete. 在此传输期间,我订阅了UploadProgressEvent,该事件接收已传输的字节和完成的百分比。

           uploadRequest.UploadProgressEvent +=
new EventHandler<UploadProgressArgs>
    (uploadRequest_UploadPartProgressEvent);

In this event I use the entity framework to log the bytes and the percent to a database so I can see what is going on. 在这种情况下,我使用实体框架将字节和百分比记录到数据库中,以便了解发生了什么。

      public void uploadRequest_UploadPartProgressEvent(object sender, UploadProgressArgs e)
{
AppDbContext db = new AppDbContext (ConfigurationManager.ConnectionStrings["name"].ConnectionString);
        BlobTriggerLog r = new BlobTriggerLog() { blobName = this.blobName, started = DateTime.Now, awsPercent = e.PercentDone, awsBytesCopied = e.TransferredBytes };
        db.BlobTriggerLogs.Add(r);
         db.SaveChanges();
        transferPercent = e.PercentDone;
}

THE ISSUE: When I run the function locally everything consistently goes to plan, I get a log going from 0-100% complete showing that my event is fired to the end of the upload. 问题:当我在本地运行该函数时,所有事情都按计划进行,我得到了从0-100%完成的日志,表明我的事件已被触发,直到上传结束。 However, when I run the function in Azure, although the upload completes successfully, the event stops being triggered before it gets to 100%. 但是,当我在Azure中运行该功能时,尽管上载成功完成,但是在事件达到100%之前,该事件将停止触发。 For large files (100Mb+) it often gets to 80-98% complete before logging stops. 对于大文件(100Mb +),在停止日志记录之前,它通常已完成80-98%。 The function is marked as executed without errors in Azure. 该功能在Azure中被标记为已执行且没有错误。

Has anyone else experienced this problem? 还有其他人遇到过这个问题吗?

I have a block in my calling function to wait until the upload reaches 100%. 我的调用函数中有一个块等待上传达到100%。

            while(aws.transferPercent != 100)
        {
            Task.Delay(TimeSpan.FromSeconds(0.5)).Wait();
        }

aws.transfer percent is the variable in the same class as my progress event. aws.transfer百分比是与我的进度事件相同的类中的变量。

That might be becoz you are having bunch of logic in your callback, 可能是因为您的回调中有很多逻辑,

  public void uploadRequest_UploadPartProgressEvent(object sender, UploadProgressArgs e)
{
        // Just perform a log on e.PercentDone and you can see 100% out there.
}

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM