我们正在寻找一种开发基于Web的应用程序的方法,该应用程序可以使用恢复工具上传大文件(大小高达10 GB)。
我们希望使用python / django或C#/ asp.net开发此应用程序。
任何建议都将不胜感激。
答案 0 :(得分:1)
plupload将支持任意大小的文件。
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"})
答案 1 :(得分:0)
对于如此大的文件使用浏览器的标准上传功能是相当疯狂的。对于这样的文件,您宁愿将ftp功能暴露给磁盘,在.NET中,您可以使用Windows服务监视某个文件夹,如果某些内容被丢弃,则会相应地执行操作。 .NET有一个FileSystemWatcher class可以帮助您完成工作。