使用PreSignedUrl直接上传到S3时,FineUploader onProgress无法正确触发

时间:2016-07-18 11:51:34

标签: amazon-s3 cors fine-uploader

使用qq.s3.FineUploaderBasic将文件从客户端直接上传到PreSignedUrl。

文件上传到S3,但进度事件没有正确触发 - 在上传开始时触发一次或两次,当最后一个事件表明上传已完成但未完成时,在网络标签中您可以看到该文件仍在上传。
即使在2MB文件中也值得注意。

这是使用debug时的控制台:对于2140K文件是true

    Received 1 files.
    Attempting to validate image.
    Attempting to draw client-side image preview.
    Attempting to determine if test.pdf can be rendered in this browser
    First pass: check type attribute of blob object.
    test.pdf is not previewable in this browser per the blob's type attr
    Not previewable
    Sending simple upload request for 0
    Submitting S3 signature request for 0
    Sending POST request for 0
    Sending upload request for 0
    // here the upload started, put console.log at the onProgress event to log loaded, total
    // 901120 2191263
    // 2191263 2191263
    // NOTE - seems like the file finishd upload but it takes it some time to finish uploading**
    s3.fine-uploader-5.10.0.js?v=2.0.3.1:252 [Fine Uploader 5.10.0] Received response status 200 with body: 
    s3.fine-uploader-5.10.0.js?v=2.0.3.1:252 [Fine Uploader 5.10.0] Simple upload request succeeded for 0
    s3.fine-uploader-5.10.0.js?v=2.0.3.1:252 [Fine Uploader 5.10.0] Submitting upload success request/notification for 0
    s3.fine-uploader-5.10.0.js?v=2.0.3.1:252 [Fine Uploader 5.10.0] Sending POST request for 0
    s3.fine-uploader-5.10.0.js?v=2.0.3.1:252 [Fine Uploader 5.10.0] Received the following response body to an upload success request for id 0: {..}
    s3.fine-uploader-5.10.0.js?v=2.0.3.1:252 [Fine Uploader 5.10.0] Upload success was acknowledged by the server.

在fineUploader demo page上,进度正常 不同之处在于演示版没有使用签名的网址 比较请求/响应并没有找到任何不同的

以下是使用qq.FineUploaderBasic上传到我的服务器时同一文件的日志:

    Received 1 files.
    Attempting to validate image.
    Attempting to draw client-side image preview.
    Attempting to determine if test.pdf can be rendered in this browser
    First pass: check type attribute of blob object.
    test.pdf is not previewable in this browser per the blob's type attr
    Not previewable
    Sending simple upload request for 0
    // 311296 2191263
    // 1032192 2191263
    // 1064960 2191263
    // 1081344 2191263
    // 1130496 2191263
    // 1245184 2191263
    // 1507328 2191263
    // 1622016 2191263
    // 1949696 2191263
    // 2191263 2191263
    // Here the progress finished when the file actually got to my server
    xhr - server response received for 0
    responseText = {..}
    Received response status 200 with body: {..}
    Simple upload request succeeded for 0

对于如何解决这个问题的任何方向都会感到高兴,已经把progress.log放在了progressUploader代码的进度事件点上,看到它没有吞下进度事件,似乎我已经失踪了某事(可能是一个CORS问题..)

修改 在localhost上工作时出现此问题,将其上传到我的staging env并且进度条工作正常,我认为chrome和FireFox报告错误的进度当原点是localhost时

1 个答案:

答案 0 :(得分:0)

这里没有问题。该文件很可能只是很快上传。您正在上传非常小的文件,这更加复杂。上传结束时的等待是S3要么组合任何文件块,要么我们只是等待对发送完最后一个字节后发生的任何请求的响应。