无法使用blueimp将大型文件(大于2 GB)直接文件上传到s3,从而获得https://BUCKET_NAME.s3.amazonaws.com/ net :: ERR_CONNECTION_RESET

时间:2019-03-06 13:07:09

标签: amazon-web-services amazon-s3 jquery-file-upload blueimp

我在字体结尾使用了blueimp文件上传控件,并尝试上传大小超过2 GB的文件,导致BUCKET_NAME.s3.amazonaws.com/ net :: ERR_CONNECTION_RESET问题。但是,当我尝试使用具有以下参数的邮递员上传相同文件时,效果很好:

acl:VALUE_OF_ACL
policy:VALUE_OF_POLICY
AWSAccessKeyId:VALUE_OF_ACCESS_KEY
signature:VALUE_OF_SIGNATURE
key:SOME_PREFIX/postman/2gb2.pptx

在我的代码中,我可以上传大于1.5 GB的文件,但工作正常。根据s3规范,它应该能够为单个放置对象上传5GB的文件。

我创建了具有长时限的保单,并尝试以30分钟的短时限但没有运气。

我的代码段如下:

<form id="fileupload" action="BUCKET_NAME.s3.amazonaws.com" method="POST" enctype="multipart/form-data">
    <div id="dropzone" tabindex="0" class="fade well" >
    <input type="hidden" name="policy" />
    <input type="hidden" name="AWSAccessKeyId"/>
    <input type="hidden" name="key"/>
    <input type="hidden" name="acl"/>
    <input type="hidden" name="signature"/>

    <div >
        <span ><img src="${wikiServerURL}/images/cloud-upload.png" style="width:50px;" /> Drop files to attach or</span> 
        <span class="fileinput-button"> browse

                <input type="file" name="file" multiple>

        </span>
    </div>
    </div>
    <div class="fileupload-buttonbar">
        <div class="fileupload-buttons" style="width: 100%; ">
            <button type="submit" class="start"  id="start_upload_file" style="display:none;"></button>
        </div>
    </div>
    <!-- The table listing the files available for upload/download -->
    <table role="presentation" cellspacing="0" cellpadding="0"><tbody class="files"></tbody></table>
</form>





        $('#fileupload').fileupload({
            dropZone: $('#dropzone'),
            drop: function (e, data) {
                $.each(data.files, function (index, file) {
                    console.log('Dropped file: ' + file.name);
                });
            },
            change: function (e, data) {
                $.each(data.files, function (index, file) {
                    console.log('Selected file: ' + file.name);
                });
            }, 
            added:function(e, data) {

                getFileUploadDetail(function (s3UploadMetadata) {
                    var form = new FormData();
                    form.append("acl", s3UploadMetadata.acl);               
                    form.append("policy", VALUE_OF_POLICY);
                    form.append("signature", VALUE_OF_SIGNATURE);                   
                    form.append("AWSAccessKeyId", VALUE_OF_ACCESS_KEY);
                    data.formData = form;
                    form.append("key", s3UploadMetadata.key);

                    setParentDataAndFrameSize(data);


                    },data.files[0].name);


            },
            getFilesFromResponse: function (data) {

                var filesMetadata = [];
                var metadata = {};

                metadata.name = data.files[0].name;
                metadata.size = data.files[0].size;
                metadata.thumbnailUrl = "SOME_URL";
                metadata.deleteType = "GET";
                filesMetadata.push(metadata);

                return filesMetadata;
            },
            destroyed: function (e, data) {

            },
            autoUpload: false,
            sequentialUploads: true,
            disableImageResize: true,
            maxChunkSize: 0,
            maxFileSize: 10000000000, // 100GB
            paramName: 'file' 
        }

我也尝试了逐块上传,但是在第一个块出现Bad Request(400)错误之后。尽管我在第一个块之后从s3获得了Etag,但是我不知道如何在blueimp中使用ETag。需要帮助。

0 个答案:

没有答案