TAzureBlobService 和 TAmazonStorageService 的进度事件
将数据上传或下载到云服务时(使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OnWork
事件由TIdComponent
公开,TIdCustomTCPClient
和TIdIOHandler
均源自该事件。TIdIOHandler
不是一个接口。在内部,
TIdCustomTCPClient
挂钩到分配给它的任何IOHandler
的OnWork
事件。您应该将事件处理程序分配给由TIdCustomTCPClient
提供的OnWork
事件,而不是直接分配给TIdIOHandler
。那么在运行时分配什么类型的 IOHandler 就不再重要了。The
OnWork
events are exposed byTIdComponent
, which bothTIdCustomTCPClient
andTIdIOHandler
derive from.TIdIOHandler
is not an interface.Internally,
TIdCustomTCPClient
hooks into theOnWork
events of whateverIOHandler
is assigned to it. You should assign your event handlers to theOnWork
events provided byTIdCustomTCPClient
, notTIdIOHandler
directly. Then it will not matter what kind ofIOHandler
gets assigned at runtime.