繁体   English   中英

上传100%后,Blueimp jquery文件上传插件抛出错误,机架空间云存储

[英]Blueimp jquery file upload plugin throwing error after uploading 100% is done to rackspace cloud storage

我一直在尝试从我的网站上传文件到rackspace存储。 我按照以下api指南创建了将文件上传到rackspace的表单。 http://docs.rackspace.com/files/api/v1/cf-devguide/content/FormPost-d1a555.html第7.2,7.2.1和7.2.2节

如果我做一个普通的表单提交,它完全正常。 该文件上传到rackspace存储并返回状态201和空白消息。 我检查了容器中的文件并成功上传了。

但是现在当我尝试使用Blueimp jQuery文件上传插件集成进度条时问题就出现了。

这是我的初始化fileupload插件的代码

$(function () {
'use strict';

// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({maxChunkSize: 10000000});




if (window.location.hostname === 'blueimp.github.com') {
    // Demo settings:
    $('#fileupload').fileupload('option', {
        url: '//jquery-file-upload.appspot.com/',
        maxFileSize: 5000000,
        acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
        process: [
            {
                action: 'load',
                fileTypes: /^image\/(gif|jpeg|png)$/,
                maxFileSize: 20000000 // 20MB
            },
            {
                action: 'resize',
                maxWidth: 1440,
                maxHeight: 900
            },
            {
                action: 'save'
            }
        ]
    });
    // Upload server status check for browsers with CORS support:
    if ($.support.cors) {
        $.ajax({
            url: '//jquery-file-upload.appspot.com/',
            type: 'HEAD'
        }).fail(function () {
            $('<span class="alert alert-error"/>')
                .text('Upload server currently unavailable - ' +
                        new Date())
                .appendTo('#fileupload');
        });
    }
} else {
    // Load existing files:
    console.log("mukibul");
    $('#fileupload').each(function () {
        var that = this;
        console.log("result1");
        $.getJSON(this.action, function (result) {

            if (result && result.length) {
                console.log("result");
                console.log(result);
                $(that).fileupload('option', 'done')
                    .call(that, null, {result: result});
            }
        });
    });
}});

这是上传文件的网络表单

<form id="fileupload" action="https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_4d6c7b53-7b5a-458c-8a2d-957971f293bb/tranceyatralocal/${sessionScope.tyUser.userID}/${albumDetails.albumId}" method="POST" enctype="multipart/form-data">
    <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
     <input type="hidden" name="redirect" value="http://localhost:8080/impianlabs/home/uploadResponse.htm" />
        <input type="hidden" name="max_file_size" value="${max_file_size}" />
        <input type="hidden" name="max_file_count" value="10" />
        <input type="hidden" name="expires" value="${expires}" />
        <input type="hidden" name="signature" value="${hmac}" />
    <div class="row fileupload-buttonbar" style="margin:10px;">
        <div class="span7" style="">
            <!-- The fileinput-button span is used to style the file input field as button -->
            <span class="btn btn-success fileinput-button">
                <i class="icon-plus icon-white"></i>
                <span>Add files...</span>
                 <input type="file" name="files[]" multiple>
            </span>
            <button type="submit" class="btn btn-primary start">
                <i class="icon-upload icon-white"></i>
                <span>Start upload</span>
            </button>
            <button type="reset" class="btn btn-warning cancel">
                <i class="icon-ban-circle icon-white"></i>
                <span>Cancel upload</span>
            </button>
            <button type="button" class="btn btn-danger delete">
                <i class="icon-trash icon-white"></i>
                <span>Delete</span>
            </button>
            <input type="checkbox" class="toggle">
        </div>
        <!-- The global progress information -->
        <div class="span5 fileupload-progress fade">
            <!-- The global progress bar -->
            <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                <div class="bar" style="width:0%;"></div>
            </div>
            <!-- The extended global progress information -->
            <div class="progress-extended">&nbsp;</div>
        </div>
    </div>
    <!-- The loading indicator is shown during file processing -->
    <div class="fileupload-loading"></div>
    <br>
   <!--  <div>
        <ul id="filePreview">

        </ul>
    </div> -->




    <!-- The table listing the files available for upload/download -->





    <table role="presentation" class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
</form>

当我上传任何文件时,它会正常开始上传,进度会按预期开始显示。 在chrome Inspect-> Network选项卡中,我可以看到两个对rackspace服务器的请求。 一个是返回200的方法OPTIONS,另一个是方法POST,它保持在Pending中直到进度条达到100%但是一旦达到100%,POST方法的状态就会变为取消,jquery文件上传插件会输出错误true网页。 我无法理解为什么插件会抛出错误。 我检查了容器,发现该文件已成功上传。

我使用curl设置机架空间中CORS所需的所有头。 但不确定我做错了什么。 任何帮助解决这个问题将不胜感激。

注意:我正在使用spring mvc进行应用程序。

谢谢,Mukibul

目前,Cloud Files和底层的Openstack Swift组件确实支持POST上传,因为您已经成功(Docs here here here )。 遗憾的是,由于响应中缺少标头,似乎存在一个已知问题阻止CORS正常工作。

此更改已合并为master,但尚未部署到Rackspace的Cloud Files运行版本。 我在我们的CF团队的时间表上询问了这个问题,因此我们可以为此做出真正的解决方案。

更新:脚本无法在Chrome中上传,但可以在Firefox中使用。 Chrome会报告POST已取消,如您所述,但Firefox会完成它并获得HTTP 303响应以及预期的重定向URI,并且该文件存在于容器中。 我正在查看插件的代码,看看它如何处理它的响应中的成功/失败。

刚刚从Rackspace发现这个合并不在路线图中,目前也没有进行测试。 我不认为这会在不久的将来出现。

希望有一天他们会实施它。 现在,我只是在将其提供给浏览器之前覆盖控制器中页面的标题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM