0

使用 ' https://github.com/blueimp/jQuery-File-Upload ' 插件通过 100MB 块上传 4GB 文件。检查客户端-服务器交互,注意到加载 2GB 后上传失败。检查 firebug 控制台,该插件似乎正在尝试在 2GB 内容范围内重新发送相同的 100MB 块。我正在说明下面的请求/响应标头以及使用插件提供的默认 php 库从服务器收到的响应。

第一个输出代表 1.8GB - 1.9GB 传输 第二个输出代表 1.9GB - 2GB 传输。第三个输出是在下一个 AJAX 请求期间发生的情况。它似乎试图转移另一个片段,服务器现在响应一个稍微不同的 JSON 消息,将“type”属性设置为“multipart/form-data”,而不是之前返回的通常的“video/mp4”。客户端上的 Jquery-file-upload 将继续向服务器发送具有相同范围的进一步 AJAX 请求,直到手动停止。

服务器环境 Apache/2.2.22,“带有 Suhosin-Patch 的 PHP 5.3.10-1ubuntu3.7”,“Ubuntu 12.04.1 LTS”。

客户端环境 Windows 7、Firefox 24。

客户端 Javascript 实现:

<script src="/js/vendor/jquery.ui.widget.js"></script>
<script src="/js/jquery.iframe-transport.js"></script>
<script src="/js/jquery.fileupload.js"></script>

<script>
$(function () {
   'use strict';

    $('#fileupload').fileupload({
     maxChunkSize: 100000000, // 100 MB   */
    url: '/uploadify/jquery_video_upload_submit',
    dataType: 'json',
    done: function (e,data) {
        $.each(data.result.files, function (index, file) {
            $('<p/>').text(file.name).appendTo('#files');
        });
    },
    progressall: function (e, data) {
        var progress = parseInt(data.loaded / data.total * 100, 10);
        $('#progress .progress-bar').css(
            'width',
            progress + '%'
        );
    }
}).prop('disabled', !$.support.fileInput)
    .parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>

服务器端实现

public function jquery_video_upload_submit(){   
    $this->output->set_header('Content-Type: application/json; charset=utf-8');
    error_reporting(E_ALL | E_STRICT);
    $this->load->library('uploadHandler');
}

观察到的输出 1:

响应标头

Access-Control-Allow-Cred...    false
Access-Control-Allow-Head...    Content-Type, Content-Range, Content-Disposition
Access-Control-Allow-Meth...    OPTIONS, HEAD, GET, POST, PUT, PATCH, DELETE
Access-Control-Allow-Orig...    *
Cache-Control   no-store, no-cache, must-revalidate
Connection  Keep-Alive
Content-Disposition inline; filename="files.json"
Content-Length  204
Content-Type    application/json; charset=utf-8
Date    Mon, 21 Oct 2013 15:02:28 GMT
Keep-Alive  timeout=5, max=93
Pragma  no-cache
Range   0-1899999999
Server  Apache/2.2.22 (Ubuntu)
Vary    Accept
X-Content-Type-Options  nosniff

请求标头

Accept  application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Content-Disposition attachment; filename="block%20burner%20movie%2011.1.10(1).mp4"
Content-Length  100000211
Content-Range   bytes 1800000000-1899999999/4122624072
Content-Type    multipart/form-data; boundary=---------------------------1694899034803
Cookie  ci_session=****;         
Host    dev.****.tv
Referer http://dev.****.tv/tests/jqueryfileupload
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0
X-Requested-With    XMLHttpRequest

回复:

{"files":[{"name":"block burner movie 11.1.10(1).mp4","size":1900000000,"type":"video\/mp4","deleteUrl":"http:\/\/dev.****.tv\/?file=block%20burner%20movie%2011.1.10%281%29.mp4","deleteType":"DELETE"}]}

观察到的输出 2:

响应标头

Access-Control-Allow-Cred...    false
Access-Control-Allow-Head...    Content-Type, Content-Range, Content-Disposition
Access-Control-Allow-Meth...    OPTIONS, HEAD, GET, POST, PUT, PATCH, DELETE
Access-Control-Allow-Orig...    *
Cache-Control   no-store, no-cache, must-revalidate
Connection  Keep-Alive
Content-Disposition inline; filename="files.json"
Content-Length  204
Content-Type    application/json; charset=utf-8
Date    Mon, 21 Oct 2013 15:03:27 GMT
Keep-Alive  timeout=5, max=92
Pragma  no-cache
Range   0-1999999999
Server  Apache/2.2.22 (Ubuntu)
Vary    Accept
X-Content-Type-Options  nosniff

请求标头

Accept  application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Content-Disposition attachment; filename="block%20burner%20movie%2011.1.10(1).mp4"
Content-Length  100000215
Content-Range   bytes 1900000000-1999999999/4122624072
Content-Type    multipart/form-data;   boundary=---------------------------280133237112097
Cookie  ci_session=****
Host    dev.****.tv
Referer http://dev.****.tv/tests/jqueryfileupload
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0
X-Requested-With    XMLHttpRequest

回复

{"files":[{"name":"block burner movie 11.1.10(1).mp4","size":2000000000,"type":"video\/mp4","deleteUrl":"http:\/\/dev.****.tv\/?file=block%20burner%20movie%2011.1.10%281%29.mp4","deleteType":"DELETE"}]}

观察到的输出 3:

响应标头

Access-Control-Allow-Cred...    false
Access-Control-Allow-Head...    Content-Type, Content-Range, Content-Disposition
Access-Control-Allow-Meth...    OPTIONS, HEAD, GET, POST, PUT, PATCH, DELETE
Access-Control-Allow-Orig...    *
Cache-Control   no-store, no-cache, must-revalidate
Connection  close
Content-Disposition inline; filename="files.json"
Content-Length  266
Content-Type    application/json; charset=utf-8
Date    Mon, 21 Oct 2013 15:04:26 GMT
Pragma  no-cache
Range   0-1999999999
Server  Apache/2.2.22 (Ubuntu)
Vary    Accept
X-Content-Type-Options  nosniff

请求标头

Accept  application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Content-Disposition attachment; filename="block%20burner%20movie%2011.1.10(1).mp4"
Content-Length  100000213
Content-Range   bytes 2000000000-2099999999/4122624072
Content-Type    multipart/form-data; boundary=---------------------------23653531328930
Cookie  ci_session=****
Host    dev.****.tv
Referer http://dev.****.tv/tests/jqueryfileupload
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0
X-Requested-With    XMLHttpRequest

回复

{"files":[{"name":"block burner movie 11.1.10(1).mp4","size":2000000000,"type":"multipart\/form-data; boundary=---------------------------23653531328930","deleteUrl":"http:\/\/dev.****.tv\/?file=block%20burner%20movie%2011.1.10%281%29.mp4","deleteType":"DELETE"}]}
4

1 回答 1

1

看来这是一个 Firefox Firebug 问题。如果您尝试将 +2GB 的大文件作为 blob 加载并尝试对它们进行切片,Firebug 将以不可预知的方式响应。在运行测试之前关闭 Firebug 可以正常工作,因为 Firefox 能够使用大文件(+4GB)并将它们切片(分成块)而没有任何问题。

于 2013-10-28T20:37:58.100 回答