在服务器上存储文件(按块上传)的最佳方法?
基本上我正在寻找一种在服务器上存储部分上传的最佳方法。文件将逐块上传。块可以并行且以任意顺序出现。我需要以某种形式将它们临时存储在某个地方,然后用上传的块构建完整的文件。我对如何做到这一点有一些想法,但我想知道是否已经有一些最佳实践、标准或某种 RFC...?
更新:
上传将通过 HTTP 进行。
Basically I'm looking for a best way to store partial uploads on server. Files are going to be uploaded chunk by chunk. Chunks may come in parallel and in arbitrary order. I will need to temporarily store them somewhere in somewhat form and then construct complete file out of uploaded chunks. I've got some ideas of how to do that, but I wonder if there is some best practice already, or a standard, or RFC of some kind..?
UPDATE:
Upload will happen via HTTP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题之前已经解决过很多次了。使用 BITS、Torrent、FTP 等
基础知识是:
>会话初始化
>发送文件名、块大小、块数、每个块的哈希
>收到信号时发送块。每个块以块索引号
< 开始。接收文件名等
<分配正确名称和大小的空文件
<分配完成文件(例如 name.status)并为每个块分配一个 int。这些代表该块的完成百分比
<; 处启动块
发出信号以在所需索引 << 接收每个块时,将其保存到分配的文件中的正确位置
<<当每个块完成时,确认哈希值。若错则重新标记为0%
<当接收到所有块时删除 name.status 并解锁分配的文件
一些系统使用大块并将文件名,大小等放在所有块的前面,因此块是独立的并且可以在没有会话启动的情况下接收
This problem has been solved many times before. Use BITS, Torrents, FTP etc
The basics are:
> session initialisation
> send file name, chunk size, number of chunks, hash of each chunk
> send chunk(s) when signalled. Each chunk starts with chunk index number
< receive file name etc
< allocate empty file of correct name and size
< allocate completion file (say name.status) and have one int per chunk. These represent percent complete of that chunk
< signal to start chunks at required indexes
<< As each chunk is being received, save into allocated file at correct location
<< As each chunk is completed confirm hash. If wrong mark as 0% again
< when all chunks are received remove name.status and unlock allocated file
Some systems use large chunks and put file name, size etc at front of all chunks, So chunks are independent and can be received without session initiation