TAzureBlobService 和 TAmazonStorageService 的进度事件

发布于 2025-01-08 10:27:52 字数 605 浏览 3 评论 0原文

将数据上传或下载到云服务时(使用 TAzureBlobService 或 TAmazonStorageService),似乎没有任何方法可以获取有关上传/下载进度的反馈。

我可以看到,最终 TIdTCPClientCustom.Connect 被调用,并且在该函数中,如果连接不存在,它会创建一个默认的 IOHandler(除非使用 SSL,否则它不会存在)。如果我可以为该 IOHandler 设置 OnWorkBegin、OnWorkEnd 和 OnWork 事件,那么我就可以跟踪进度,但我无法做到这一点。

如果使用 SSL 连接,则会创建 IOHandler(例如在 TAzureBlobService.PrepareRequest 中),但 IOHandler 是一个接口,没有 OnWorkBegin 等属性。

我认为解决方案是创建一个从 TAzureBlobService 或 TAmazonStorageService 派生的类,然后重写PrepareRequest 方法。这样我就可以访问 TCloudHTTP 实例(因为它是在PrepareRequest 中创建的),并且从中我可以访问 IOHandler。但是我如何创建 IOHandler (因为它被定义为一个接口)并设置事件(不属于该接口的一部分)?

谢谢

When uploading or downloading data to the cloud services (using TAzureBlobService or TAmazonStorageService), there doesn't appear to be any way to get feedback on the upload/download progress.

I can see that eventually TIdTCPClientCustom.Connect is called, and in that function it creates a default IOHandler for the connection if one doesn't exist (and it doesn't unless SSL is used). If I could set the OnWorkBegin, OnWorkEnd, and OnWork events for that IOHandler then I could track the progress, but there's no way I can see to do that.

If an SSL connection is used, then an IOHandler is created (e.g. in TAzureBlobService.PrepareRequest), but the IOHandler is an interface and has no OnWorkBegin etc. properties.

I think the solution is to create a class descended from TAzureBlobService or TAmazonStorageService, then override the PrepareRequest method. In that I can get access to the TCloudHTTP instance (as it is created in PrepareRequest), and from that I can get access to IOHandler. But how do I create that IOHandler (as it is defined as an interface) and set the events (which aren't part of that interface) ?

Thanks

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

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

发布评论

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

评论(1

寄居人 2025-01-15 10:27:52

OnWork 事件由 TIdComponent 公开,TIdCustomTCPClientTIdIOHandler 均源自该事件。 TIdIOHandler 不是一个接口。

在内部,TIdCustomTCPClient 挂钩到分配给它的任何 IOHandlerOnWork 事件。您应该将事件处理程序分配给由 TIdCustomTCPClient 提供的 OnWork 事件,而不是直接分配给 TIdIOHandler。那么在运行时分配什么类型的 IOHandler 就不再重要了。

The OnWork events are exposed by TIdComponent, which both TIdCustomTCPClient and TIdIOHandler derive from. TIdIOHandler is not an interface.

Internally, TIdCustomTCPClient hooks into the OnWork events of whatever IOHandler is assigned to it. You should assign your event handlers to the OnWork events provided by TIdCustomTCPClient, not TIdIOHandler directly. Then it will not matter what kind of IOHandler gets assigned at runtime.

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