blueimp文件上传器直接上传到AWS S3替换上一部分

时间:2018-02-03 12:24:21

标签: javascript jquery amazon-s3 file-upload blueimp

我使用以下插件直接在AWS S3上上传大文件而不使用任何服务器。 https://github.com/blueimp/jQuery-File-Upload/wiki/Upload-directly-to-S3

它适用于小文件,但是当我使用" maxChunkSize"参数如其文档中所述,它可以工作,但它取代了以前的部分。

假设有一个100 MB的文件,并且我成功上传后使用10MB块上传它我在S3存储桶上只收到10 MB。

请帮我解决这个问题。

这是使用

的JS代码
$('#file_upload').fileupload({
                autoUpload: false,
                maxChunkSize: 10000000, // 10 MB => 10000000
                add: function (e, data) {
                    $("#upload_btn").off('click').on('click', function (evt) {
                        evt.preventDefault();
                        data.submit();
                    });
                },
                send: function (e, data) {
                    // show a loading spinner because now the form will be submitted to amazon, 
                    // and the file will be directly uploaded there, via an iframe in the background. 
                    $('#loading').show();
                },
                fail: function (e, data) {
                    console.log('fail');
                    console.log(data);
                },
                done: function (event, data) {
                    // here you can perform an ajax call to get your documents to display on the screen.
                    //alert('complete');
                    // hide the loading spinner that we turned on earlier.
                    $('#loading').hide();
                },
                progress: function (e, data) {
                    var progress = parseInt(data.loaded / data.total * 100, 10);
                    $('.progress').css('width', progress + '%');
                }
            });

1 个答案:

答案 0 :(得分:1)

当我查看互联网上提供的blueimp文档时,它无法将文件从浏览器上传到AWS S3。

有一个更好的库可用于直接从浏览器上传文件到块上的AWS S3。

https://github.com/TTLabs/EvaporateJS

我已经用2 GB文件对其进行了测试,并且工作正常。

我会在几天内添加一个工作示例。

相关问题