1

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

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

任何建议将不胜感激。

4

2 回答 2

1

带有 Java 后端的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"})
于 2011-11-03T22:57:18.180 回答
0

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

于 2010-09-13T11:37:12.070 回答