【问题标题】:Upload files with Dropzone multipart only upload last part (chunk)使用 Dropzone 多部分上传文件仅上传最后一部分(块)
【发布时间】:2019-10-06 15:55:45
【问题描述】:

我正在尝试使用 Dropzone js 将大文件(视频)分段上传到 Wasabi(AWS 副本)。我得到的错误是只上传最后一个块。而且我不知道为什么,但是 dropzone 最后一次调用不编译文件。我尝试了不同的方法,但没有人为我工作。这是我的 dropzone 对象:

var dropzone = new Dropzone('#video-dropzone', {
            previewTemplate: document.querySelector('#preview-template').innerHTML,
            parallelUploads: 2,
            thumbnailHeight: 120,
            thumbnailWidth: 120,
            method: 'POST',
            paramName: "file",
            autoProcessQueue: false,
            timeout: 7200000,
            maxFilesize: 500000,
            chunking: true,
            parallelChunkUploads: false,
            chunkSize: 100000000, {# 1000000000   1GB per part #}
            params: function (files, xhr, chunk) {
            if (chunk) {
                return {
                    UploadId: chunk.file.upload.uuid,
                    PartNumber: chunk.index,
                    TotalFileSize: chunk.file.size,
                    CurrentChunkSize: chunk.dataBlock.data.size,
                    TotalChunkCount: chunk.file.upload.totalChunkCount,
                    ChunkByteOffset: chunk.index * this.options.chunkSize,
                    ChunkSize: this.options.chunkSize,
                    Filename: chunk.file.name,
                };
            }
        },
            init: function () {
                thisDropzone = this;
                {# When a file is added, we need to put the fields of the video, #}
                {# so we show a video create form #}
                thisDropzone.on('addedfile', function (file) {
                    thisDropzone.options.url = $("#video-dropzone").attr("action");
                    $.confirm({
                        title: "{% trans 'Video Create' %}",
                        content: 'url:{% url 'video-create' %}',
                        useBootstrap: false,
                        theme: 'material',
                        buttons: {
                            create: function () {
                                {# If the title is empty, you can't create it #}
                                if ($("#id_title").val() == "") {
                                    $("#id_title").addClass("is-invalid");
                                    return false;
                                }
                                {# Creation of the video fields #}
                                let create_video = video_create(file);

                                {# If all fields has been created correctly,#}
                                {# the generate a signature and launch the queue #}
                                if (create_video.status == 200) {
                                    file.customName = create_video.data.filename;

                                    generar_signature(file);

                                    {# When all fields are correct, the dropzone can start#}
                                    {# to upload the files #}
                                    thisDropzone.processQueue();
                                }

                            },
                            cancel: function () {
                                {# Removes the file if you click cancel #}
                                thisDropzone.removeFile(file);
                            }
                        }
                    });

                });

它正确地对文件进行分块,但是当在存储中完成时,我只看到最后一部分

【问题讨论】:

  • 您是否也将发布您的服务器端代码,以便我们了解您如何处理服务器端的上传?
  • 你解决了吗?

标签: amazon-web-services amazon-s3 multipartform-data dropzone.js


【解决方案1】:

这是因为每次调用 chunk 时都会调用 API。 因此它只存储最后一个块。 您必须将每个块存储到一个 byteArray(全局)中并相应地处理它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-16
    • 2021-01-19
    • 2013-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-15
    • 2014-10-31
    相关资源
    最近更新 更多