gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 07:23:06 27 4
gpt4 key购买 nike

我正在尝试使用 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com