c# - 如何在 .NET C# 中取消长时间运行的 Amazon Glacier 文件上传操作

标签 c# asynchronous task-parallel-library .net-4.5 amazon-glacier

我是 Amazon AWS 和 Glacier 的新手。 我正在尝试编写一个基于 WPF Windows 的 C# 客户端,将我的存档备份数据上传到冰川云。 但是,API 引用似乎没有提供取消命令。仅上传、下载、列表。

我想做的是使用 TPL 异步运行每个上传操作(对于大文件可能需要 1 小时或更长时间)。 但是我希望上传是可取消的,.NET 4.5 会很好地支持,但 Amazon API 不支持。

有没有办法做到这一点?

谢谢。

最佳答案

Amazon Glacier 中处理您的场景的推荐方法(还有 Amazon S3 顺便说一句。)是通过分段上传分段上传文件,参见Uploading an Archive in Amazon Glacier :

Depending on the size of the data you are uploading, Amazon Glacier offers the following options:

  • Uploading Large Archives in Parts (Multipart Upload) — In a single operation, you can upload archives from 1 byte to up to 4 GB in size. However, we encourage Amazon Glacier customers to use Multipart Upload to upload archives greater than 100 MB. [...] [emphasis mine]

  • Upload archives in parts — Using the Multipart upload API you can upload large archives, up to about 40,000 GB (10,000 * 4 GB).

Uploading Large Archives in Parts (Multipart Upload)提供有关后者的详细信息,特别是关于完成(或中止)分段上传:

After uploading all the archive parts, you use the complete operation. [...]

If you abort a multipart upload, you cannot upload any more parts using that multipart upload ID. All storage consumed by any parts associated with the aborted multipart upload is freed. If any part uploads were in-progress, they can still succeed or fail even after you abort. [emphasis mine]

因此,您仍然无法中止正在上传的部分,因此,获得所需用户体验和/或减少网络带宽的关键是选择足够小的部分大小。

根据您的用例,您可能还想查看 List Multipart Uploads (GET multipart-uploads) :

This multipart upload operation lists in-progress multipart uploads for the specified vault. An in-progress multipart upload is a multipart upload that has been initiated by an Initiate Multipart Upload (POST multipart-uploads) request, but has not yet been completed or aborted. [...]

关于c# - 如何在 .NET C# 中取消长时间运行的 Amazon Glacier 文件上传操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12560345/

相关文章:

c# - 多次调用 GetStringAsync 的更有效方法?

c# - 将 NULL 传递给 COM 接口(interface)方法的 ref/out 参数

c# - 如何减少连续触发事件的事件处理频率

c# - 当线程等待到达锁定语句时记录

loops - Coldfusion - 数据库记录更新时刷新页面

c# - NUnit 不等待异步任务完成

java - Spring - @Async 在手动创建组件时不起作用

c# - 将 wchar_t 转换为 Char

c# - 使用多个 IF 构建 FOR 循环并使其仅在某些运行中停止

c# - 使用nuget时,我该如何解决dll hell?