amazon-web-services - 使用 Dropzone 多部分上传文件只上传最后一部分( block )

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

我正在尝试使用 Dropzone js 将大文件(视频)分段上传到 Wasabi(AWS 副本)。我得到的错误是只上传最后一个 block 。我不知道为什么,但 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);
                            }
                        }
                    });

                });

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

最佳答案

这是因为每次调用 chunk 时都会调用 API。 因此它只存储最后一个 block 。 您必须将每个 block 存储到字节数组(全局)中并进行相应处理

关于amazon-web-services - 使用 Dropzone 多部分上传文件只上传最后一部分( block ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56218223/

相关文章:

java - 创建包含分段文件上传的发布请求

Android 上的 Java 访问分段上传的共享首选项时出错

amazon-web-services - 推荐 Cassandra 的 AWS 存储类型?

python - 如何从 s3 存储桶和单独的事件 JSON 加载依赖项?

java - com.amazonaws.services.s3.model.AmazonS3Exception : Access Denied

apache-spark - 提供者 org.apache.hadoop.fs.s3a.S3AFileSystem 无法实例化

windows - PHP Kohana 3.2.2 多部分形式 $_POST 未在 MAC 上设置但适用于 Win

amazon-web-services - AWS CloudWatch 日志 : How to send an email notification when particular error message is logged by lambda

amazon-web-services - 在 TerraForm 的中心部分定义标签

amazon-web-services - 使用 Athena 查询 s3 中的 AWS firehose 数据 - 无法查询批处理