We are looking for an approach for developing a web based application which should have facility to upload large files (size upto 10 GB) with resume开发者_运维问答 facility.
We want to develop this application using python/django or C#/asp.net.
Any suggestion would be appreciated.
plupload with the Java backend will support files up to any size.
https://github.com/jakobadam/plupload-java-runtime
You will need to port the uploading portion to Django. It would be something like this. Although this does not do any checksum verification.
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"})
Using the standard upload functionality of the browser for such large files is rather insane. For such files you rather expose ftp functionality to a disk where you can have, in .NET, have a windows service monitor a certain folder and if something gets dropped there act accordingly. .NET has a FileSystemWatcher class available to aid you in your effort.
精彩评论