使用django或asp.net中的resume工具上载基于Web的大型文件
我们正在寻找一种开发基于web的应用程序的方法,该应用程序应该具有使用resume功能上载大文件(大小高达10GB)的功能 我们希望使用python/django或C#/asp.net开发此应用程序使用django或asp.net中的resume工具上载基于Web的大型文件,asp.net,python,django,file-upload,uploading,Asp.net,Python,Django,File Upload,Uploading,我们正在寻找一种开发基于web的应用程序的方法,该应用程序应该具有使用resume功能上载大文件(大小高达10GB)的功能 我们希望使用python/django或C#/asp.net开发此应用程序 如果您有任何建议,我们将不胜感激。对于如此大的文件,使用浏览器的标准上载功能是相当疯狂的。对于这样的文件,您更愿意将ftp功能公开到一个磁盘上,在.NET中,您可以在该磁盘上有一个windows服务监视器来监视某个文件夹,如果有东西掉在那里,则相应地采取行动。NET有一个可用的工具来帮助您完成工作。
如果您有任何建议,我们将不胜感激。对于如此大的文件,使用浏览器的标准上载功能是相当疯狂的。对于这样的文件,您更愿意将ftp功能公开到一个磁盘上,在.NET中,您可以在该磁盘上有一个windows服务监视器来监视某个文件夹,如果有东西掉在那里,则相应地采取行动。NET有一个可用的工具来帮助您完成工作。使用浏览器的标准上载功能来处理如此大的文件是相当疯狂的。对于这样的文件,您更愿意将ftp功能公开到一个磁盘上,在.NET中,您可以在该磁盘上有一个windows服务监视器来监视某个文件夹,如果有东西掉在那里,则相应地采取行动。NET有一个可用于帮助您完成工作的工具。使用Java后端将支持任何大小的文件 您需要将上传部分移植到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"})
Java后端将支持任何大小的文件
您需要将上传部分移植到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"})