asp.net - 基于 Web 的大文件上传,带有 django 或 asp.net 中的恢复功能

标签 asp.net python django file-upload uploading

我们正在寻找一种开发基于 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/

相关文章:

ASP.Net ScriptControl - 从另一种方法调用一种方法

c# - GridView 必须放置在带有 runat ="server"的表单标签内,即使在 GridView 位于表单标签内之后也是如此

python - 用python优化opencv的骨架函数

python - 如何在 tastypie 中使用自定义用户类型限制 GET、POST 对资源的访问

python - 如何在 drf_yasg 中将方案从 HTTP 更改为 HTTPS?

asp.net - ASP.NET 中的 NLog - 日志文件应该有什么权限(归档问题)

asp.net - Web api 和 Angularjs 身份验证失败

python - 在 Python 中拆分连接字符串的正确而优雅的方法

python - 使用 ctypes (Python->C++) 提交 'int' 和 'string' 数组

django - 在 django : getting "global name context is not defined" error 中上传图片