简体   繁体   English

在服务器端检查文件下载进度?

[英]Checking the progress of file download on the server side?

I am trying to build a service which allows to download music files. 我正在尝试建立允许下载音乐文件的服务。 However after a user pays for a song, I want to be able to verify if the file was completely downloaded by the user or if the download failed in between. 但是,在用户支付一首歌曲的费用之后,我希望能够验证该文件是否已由用户完全下载,或者两次下载之间是否失败。 How can this be exercised? 如何行使呢? Thanks. 谢谢。

Theoretically you never know how many remaining packets the client will request. 从理论上讲,您永远不知道客户端将请求剩余多少个数据包。 Therefore i see two options: 因此,我看到两个选择:

  1. Dig deeeeep into your server code and come up with some hacky solution that somehow checks sent packets and tries to predict download completion 挖掘deeeeep到您的服务器代码中,并提出一些黑客解决方案,以某种方式检查发送的数据包并尝试预测下载完成

  2. Write a native application that sends the progress back to the server (of course, then you will not have a web app any more) 编写将进度发送回服务器的本机应用程序(当然,那么您将不再有Web应用程序)

As i understand user who pays for music have account on site. 据我了解,为音乐付费的用户在网站上拥有帐户。 If he payed for music, add music to user's music list. 如果他为音乐付费,则将音乐添加到用户的音乐列表中。 And he will be able to download again in future. 而且他将来将可以再次下载。 If download fail for any reason, user can re-download 如果由于任何原因下载失败,用户可以重新下载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM