Flash 8 FileReference 和文件完整性检查

发布于 2024-07-14 08:34:28 字数 663 浏览 12 评论 0原文

Flash 8 FileReference API 使您可以定期检查正在传输的字节数:(

listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
    trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}

更多信息此处此处)

如果上传,您建议使用此方法检查上传文件的完整性

Flash 8 FileReference API gives you the possibility to check periodically for the number of bytes being transmitted:

listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
    trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}

(more infos here and here)

In case of upload, would you suggest to use this method to check for the integrity of the uploaded file?

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

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

发布评论

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

评论(1

旧梦荧光笔 2024-07-21 08:34:28

只需监听 onComplete 事件即可检查文件何时正确上传。
如果到目前为止没有抛出任何错误事件,则该文件应该位于服务器上。

如果您不想信任 FlashPlayer 所发布文件的完整性(例如,您的服务器无法将其从 /tmp 文件夹中移动等),则可能需要采取一些措施来确保该过程已正确完成:

  • 检查客户端的文件大小(最好是校验和,但不认为您可以获得)。
  • 在文件上传请求中发布此信息。
  • 收到发布数据后,服务器端从接收到的文件收集相同的信息(大小、校验和),并将其与客户端生成的信息进行比较。
  • 发送回状态(失败/成功)

...除非您的应用程序非常明智,否则我会跳过此步骤,原因很简单,它可能会产生比您根本没有任何完整性检查更多的问题:)

更好:根据您发送的文件,您也许能够找到一个服务器脚本来检查文件是否正常,然后根据情况发回状态。

Just listen to the onComplete event to check whenever the file is properly uploaded.
If no error events have been thrown so far the file should be on the server.

If you don't want to trust FlashPlayer regarding the integrety of the posted file (e.g. your server failed moving it from the /tmp folder, etc. ), something likely would be necessary to make sure the procedure was finished properly :

  • Check the file size (best would be checksum, don't think you can get that though) client side.
  • Post this information within the file upload request.
  • Once the post data received, gather the same information (size, checksum) server-side from the received file and compare it with the information generated client-side.
  • Send back status (fail/success)

... Unless your application is very sensible I would skip this though, just for the simple reason that it might generate more problems than if you hadn't got any integrity-check at all : )

Better: depending on the file you send you may be able to find out a server script to check if the file looks fine and just send back a status depending on that.

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