异步上传 Azure Blob:BeginUploadFromStream 与 BackgroundWorker

发布于 2024-10-05 23:50:43 字数 226 浏览 2 评论 0原文

我正在将 blob 异步上传到 Azure Blob 存储。我可以使用 CloudBlockBlob.BeginUploadFromStream 或者使用 BackgroundWorker 调用同步 Upload 方法(如 UploadFile 或 PutBlock)。我正在寻找有关这两种方法的优缺点的一些意见。

我会让球滚起来。使用BackgroundWorker 方法报告进度似乎要容易得多。

谢谢!

I am uploading blobs asynchronously to Azure Blob Storage. I can use CloudBlockBlob.BeginUploadFromStream or I could call the synchronous Upload methods (like UploadFile or PutBlock) with a BackgroundWorker. I am looking for some opinions on the pros and cons of either approach.

I'll get the ball rolling. It appears much easier to report progress back with the BackgroundWorker approach.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

等你爱我 2024-10-12 23:50:43

BeginUploadFromStream 会更加高效,因为它使用异步编程模型,在发生 I/O 时不会占用 CPU 资源。如果您启动一个BackgroundWorker并调用任何非APM方法,那么当从磁盘读取和写入网络等事情发生时,您实际上会浪费该线程。

在 .NET 中,您几乎总是希望在 APM 模型可实现最大效率时使用它。

BeginUploadFromStream will be more efficient because it uses the asynchronous programming model which will not use up CPU resources while I/O is occurring. If you spin up a BackgroundWorker and call any of the non-APM methods your essentially wasting that thread while things like reading from disk and writing to the network are occuring.

In .NET, you pretty much always want to use the APM model when it's available for maximum efficiency.

诺曦 2024-10-12 23:50:43

我正在更新这个老问题,因为我仍然从 noir 的帖子中获得了很多博客点击量。请注意,我的博客文章有一个新版本,使用 Azure 存储客户端库 2.0 中的 *FromStream 方法。这个新代码性能更高、更可靠,并且仍然提供所有进度报告。

带有进度更改通知 2.0 的异步并行块 Blob 传输

I am updating this old question because I still get a lot of blog hits from noir's post. Please note that there is a new version of my blog post using the *FromStream methods in Azure Storage Client library 2.0. This new code is more performant and more reliable, and still provides all of the progress reporting.

Asynchronous Parallel Block Blob Transfers with Progress Change Notification 2.0

孤独岁月 2024-10-12 23:50:43

请查看这篇文章 此处

它描述了如何使用块的并行上传来上传 blob,以及报告 blob 本身的进度和并行上传。

它还链接到 如果您不想进行并行块上传,这篇好文章可能会很有用。

Please take a look at this article here.

It describes how to upload blobs using parallel upload for blocks, as well as report progress and parallel upload of blobs themselves.

It also links to this nice article which you might find useful if you don't want to do parallel block uploads.

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