我们正在寻找一种开发基于 Web 的应用程序的方法,该应用程序应该能够上传大文件(大小高达 10 GB)并具有恢复功能。
我们希望使用 python/django 或 C#/asp.net 开发此应用程序。
如有任何建议,我们将不胜感激。
最佳答案
plupload Java 后端将支持任意大小的文件。
https://github.com/jakobadam/plupload-java-runtime
您需要将上传部分移植到 Django。事情会是这样的。虽然这不做任何校验和验证。
def fileUpload(request):
"""file upload for plupload"""
if request.method == 'POST':
name = request.REQUEST.get('name','')
uploaded_file = request.FILES['file']
if not name:
name = uploaded_file.name
name,ext = os.path.splitext(name)
#check to see if a user has uploaded a file before, and if they have
#not, make them a upload directory
upload_dir = "/results/referenceLibrary/temp/"
if not os.path.exists(upload_dir):
return render_to_json({"error":"upload path does not exist"})
dest_path = '%s%s%s%s' % (upload_dir,os.sep,name,ext)
chunk = request.REQUEST.get('chunk','0')
chunks = request.REQUEST.get('chunks','0')
md5chunk = request.REQUEST.get('md5chunk', False)
md5total = request.REQUEST.get('md5total', False)
debug = [chunk, chunks, md5chunk, md5total]
with open(dest_path,('wb' if chunk==0 else 'ab')) as f:
for content in uploaded_file.chunks():
f.write(content)
if int(chunk) + 1 >= int(chunks):
#the upload has finished
pass
return render_to_json({"chuck posted":debug})
else:
return render_to_json({"method":"only post here"})
关于asp.net - 基于 Web 的大文件上传,带有 django 或 asp.net 中的恢复功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3699968/