亚马逊S3 TransferUtility.Upload挂在C#亚马逊、挂在、TransferUtility、Upload

由网友(天空蓝的掉眼泪°)分享简介:所以,我正在写一个移民申请,从我们的本地存储需要一定的数据,并上传到亚马逊。一切工作正常,但一旦我进入了大于15兆的文件(兆,是的,不是演出),该应用程序冻结。So I'm writing a migration application, to take some data from our local storag...

所以,我正在写一个移民申请,从我们的本地存储需要一定的数据,并上传到亚马逊。一切工作正常,但一旦我进入了大于15兆的文件(兆,是的,不是演出),该应用程序冻结。

So I'm writing a migration application, to take some data from our local storage and upload it to Amazon. Everything is working fine, except once I get into files that are greater than 15 megs (megs, yes, NOT Gigs), the application freeze.

这是在C#,pretty的简单。

This is in C#, pretty straightforward.

var transferRequest = new TransferUtilityUploadRequest
    {
        Key = firstKey,
        FilePath = fileName,
        BucketName = ContentBucket,
        Timeout = 3600000,
        ContentType = GetContentTypeForFileExtension(fileName)
    };

transferRequest.UploadProgressEvent += DisplayFileProgress;
transferUtil.Upload(transferRequest);

就像我说的,工作得很好的文件15兆或更小的...但在较大的,它只是停止并担任上传命令,直到永远。 15兆需要像40秒,所以我预计30兆的测试文件取,也许2分钟... ...,但10分钟后,没有爱。

Like I said, works just fine for files 15 megs or smaller...but on larger ones, it just stops and sits on the "Upload" command forever. 15 megs takes like 40 seconds, so I expected the 30 meg test file to take, maybe 2 minutes...but 10 minutes later, no love.

任何意见将是AP preciated,因为不幸的是,我会处理大量是50 +兆大小的文件。

Any advice would be appreciated, as unfortunately, I will be dealing with lots of files that are 50+ megs in size.

请注意,如果我在AWS资源管理器在Visual Studio .NET,我可以手动上传50+兆的文件,没有任何问题,比较快。

Note that if I'm in the AWS Explorer in Visual Studio .net, I can manually upload files of 50+ megs without any issue and relatively quickly.

这就是有趣...在进一步审查,我的50兆的文件上传就好了。它的code我已经连接到实际上是造成东西冻结起来,因为如果我注释掉,则50兆的文件上传没有问题的UploadProgressEvent。

So this is "interesting"...On further review, my 50 meg files are uploading just fine. Its the code I have attached to the UploadProgressEvent that is actually causing things to freeze up, because if I comment it out, then the 50 meg files upload without issue.

如果我离开这个code中,15兆的文件显示它们对进度条的进展。但任何大于15兆实际上导致整个应用程序冻结起来。谁能告诉我什么可能是与code处理进度条的更新问题?

If I leave this code in, 15 meg files show their progress on a progress bar. But anything bigger than 15 megs actually causes the whole app to freeze up. Can anyone tell me what might be the problem with the code that handles the progress bar updating?

private void DisplayFileProgress(object sender, UploadProgressArgs args)
{
    pbFileProgress.Invoke((MethodInvoker)delegate { 
        pbFileProgress.Value = args.PercentDone; 
        pbFileProgress.Refresh(); }); 
}

和我只是设置 transferRequest.UploadProgressEvent + = DisplayFileProgress 。就像我说的,有什么奇怪的是,这工作正常较小的文件,但是一切都锁起来了更大的。

And I'm just setting "transferRequest.UploadProgressEvent += DisplayFileProgress". Like I said, what's weird is that this works fine for smaller files but locks everything up for bigger ones.

推荐答案

尝试使用BeginUpload的方法,而不是上传。

Try using BeginUpload method instead of Upload.

        transferUtility.BeginUpload(request, new AsyncCallback(uploadComplete), null );
    }
    private void uploadComplete(IAsyncResult result)
    {
        var x = result;
    }

设置您的传输工具,并像前面那样UploadProgressEvent。进度处理程序中使用invoke方法像你一样。如果您使用的BeginUpdate(),而不是更新()将prevent该应用从挂在第一次更新到您的窗体。我找不到此解决方案的任何地方,所以我希望它为你工作。

Setup your transfer utility and UploadProgressEvent as you did before. Use the Invoke method within the progress handler as you did. If you use BeginUpdate() instead of Update() it will prevent the app from hanging on the first update to your form. I couldn't find this solution anywhere so I hope it works for you.

阅读全文

相关推荐

最新文章