简体   繁体   English

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

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

I have been trying to upload files to rackspace storage from my website. 我一直在尝试从我的网站上传文件到rackspace存储。 I have followed the following api guide to create the form to upload files to rackspace. 我按照以下api指南创建了将文件上传到rackspace的表单。 http://docs.rackspace.com/files/api/v1/cf-devguide/content/FormPost-d1a555.html section 7.2, 7.2.1 and 7.2.2 http://docs.rackspace.com/files/api/v1/cf-devguide/content/FormPost-d1a555.html第7.2,7.2.1和7.2.2节

It completely works fine if I do a normal form submit. 如果我做一个普通的表单提交,它完全正常。 The file gets uploaded to rackspace storage and returns a status 201 and a blank message. 该文件上传到rackspace存储并返回状态201和空白消息。 I checked the file in the container and its uploaded successfully. 我检查了容器中的文件并成功上传了。

But now the problem comes when i try to integrate progressbar using Blueimp jQuery file upload plugin. 但是现在当我尝试使用Blueimp jQuery文件上传插件集成进度条时问题就出现了。

Here's my code to initialize the fileupload plugin 这是我的初始化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});
            }
        });
    });
}});

Here's the web form to upload files 这是上传文件的网络表单

<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>

When I upload any files, it starts uploading normally, the progress starts showing up as expected. 当我上传任何文件时,它会正常开始上传,进度会按预期开始显示。 In chrome Inspect->Network tabs I could see two requests to the rackspace server. 在chrome Inspect-> Network选项卡中,我可以看到两个对rackspace服务器的请求。 One is method OPTIONS which returns 200 and another is method POST which remains in Pending until the progress bar reaches 100% but as soon as it reaches 100% the status of the POST method changes to cancelled and the jquery file upload plugin prints error true in the webpage. 一个是返回200的方法OPTIONS,另一个是方法POST,它保持在Pending中直到进度条达到100%但是一旦达到100%,POST方法的状态就会变为取消,jquery文件上传插件会输出错误true网页。 I am not able to understand why the plugin is throwing error. 我无法理解为什么插件会抛出错误。 I checked the container and found that the file got uploaded successfully. 我检查了容器,发现该文件已成功上传。

I have used curl to set all headers required for CORS in rackspace. 我使用curl设置机架空间中CORS所需的所有头。 But not sure what I am doing wrong. 但不确定我做错了什么。 Any help to resolve the issue would be appreciated. 任何帮助解决这个问题将不胜感激。

Note: I'm using spring mvc for the application. 注意:我正在使用spring mvc进行应用程序。

Thanks, Mukibul 谢谢,Mukibul

At the present time, Cloud Files and the underlying Openstack Swift component do support POST uploading as you've been successful with (Docs here and here ). 目前,Cloud Files和底层的Openstack Swift组件确实支持POST上传,因为您已经成功(Docs here here here )。 Unfortunately there appears to be a known issue that prevents CORS from working properly due to a missing header in the response. 遗憾的是,由于响应中缺少标头,似乎存在一个已知问题阻止CORS正常工作。

The change has been merged into master, but hasn't been deployed to Rackspace's running version for Cloud Files. 此更改已合并为master,但尚未部署到Rackspace的Cloud Files运行版本。 I have an inquiry in with our CF team on a timeline for having this fixed so we can come to a real resolution for this. 我在我们的CF团队的时间表上询问了这个问题,因此我们可以为此做出真正的解决方案。

UPDATE: The script fails to upload for me in Chrome, but works in Firefox. 更新:脚本无法在Chrome中上传,但可以在Firefox中使用。 Chrome reports the POST is cancelled as you described, but Firefox completes it and gets an HTTP 303 response along with the expected redirect URI and the file is present in the container. Chrome会报告POST已取消,如您所述,但Firefox会完成它并获得HTTP 303响应以及预期的重定向URI,并且该文件存在于容器中。 I'm looking at the code for the plugin to see how it handles success/failure in it's responses. 我正在查看插件的代码,看看它如何处理它的响应中的成功/失败。

Just found out from the Rackspace that this merge is not in the roadmap and is also not being tested currently. 刚刚从Rackspace发现这个合并不在路线图中,目前也没有进行测试。 I don't see this coming in near future. 我不认为这会在不久的将来出现。

Hopefully one day they will implement it. 希望有一天他们会实施它。 For now, I would just overwrite the header of the page in the controller before serving it to the browser. 现在,我只是在将其提供给浏览器之前覆盖控制器中页面的标题。

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

相关问题 使用可恢复上传 url 在 React js 中上传文件在谷歌云存储中失败,抛出 CORS 策略错误 - Uploading file in react js with resumable upload url is failing in google cloud storage, throwing CORS policy error Blueimp jQuery File Upload-上传完成后,从队列中隐藏文件 - Blueimp jQuery File Upload - hide file from queue after upload done responce blueimp jquery文件上传 - “完成”,“完成”回调不适用于IE 9 - blueimp jquery file upload - “done”, “complete” callbacks not working for IE 9 Blueimp jQuery File Upload插件-单击“开始上传”时出现配额错误 - Blueimp jQuery File Upload plugin - Over Quota Error when clicking 'Start Upload' 在Blueimp jQuery File Upload上禁用自动上传 - Disabling auto-uploading on Blueimp jQuery File Upload blueimp jquery文件上传错误.fileupload不是函数 - blueimp jquery file upload error .fileupload is not a function BlueImp文件上传插件不起作用 - BlueImp file upload plugin not working blueimp jQuery文件上传插件隐藏上传的文件 - blueimp jQuery file upload plugin hide uploaded files 在IE8 / 9中使用blueimp文件上传插件的jQuery $ _FILES数组为空 - jQuery $_FILES array empty with blueimp file upload plugin in IE8/9 BlueImp jQuery文件上传到Imgur - BlueImp jQuery File Upload to Imgur
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM