【问题标题】:Web based large files upload with resume facility in django or asp.net使用 django 或 asp.net 中的简历工具上传基于 Web 的大文件
【发布时间】:2023-04-11 03:22:01
【问题描述】:

我们正在寻找一种开发基于 Web 的应用程序的方法,该应用程序应具有上传大文件(最大 10 GB)和恢复功能的功能。

我们想使用 python/django 或 C#/asp.net 开发这个应用程序。

任何建议都将不胜感激。

【问题讨论】:

    标签: asp.net python django file-upload uploading


    【解决方案1】:

    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"})
    

    【讨论】:

      【解决方案2】:

      使用浏览器的标准上传功能来处理如此大的文件是相当疯狂的。对于此类文件,您宁愿将 ftp 功能公开到您可以拥有的磁盘上,在 .NET 中,有一个 Windows 服务监视某个文件夹,如果有东西被丢弃,则采取相应的行动。 .NET 有一个 FileSystemWatcher class 可以帮助您完成工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-04-30
        • 2010-12-13
        • 1970-01-01
        • 2010-09-16
        • 2016-01-02
        • 2011-01-05
        • 1970-01-01
        相关资源
        最近更新 更多