Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud storage 谷歌云存储文件上传-未找到请求的页面。[404]_Google Cloud Storage_Google Cloud Platform - Fatal编程技术网

Google cloud storage 谷歌云存储文件上传-未找到请求的页面。[404]

Google cloud storage 谷歌云存储文件上传-未找到请求的页面。[404],google-cloud-storage,google-cloud-platform,Google Cloud Storage,Google Cloud Platform,我正在尝试使用Json API将一个文件上传到Google云存储。我将请求与文件附件一起发布到下面的url https://www.googleapis.com/upload/storage/v1/b/mybucket/o?uploadType=media&name=solarsystemlrg.png 但我收到的请求页面未找到。[404]错误。当我使用下面的Url时,我能够列出存储在bucket中的图像(只是为了确保没有访问问题并且bucket名称正确) 我已经设置了标题 'Auth

我正在尝试使用Json API将一个文件上传到Google云存储。我将请求与文件附件一起发布到下面的url

https://www.googleapis.com/upload/storage/v1/b/mybucket/o?uploadType=media&name=solarsystemlrg.png
但我收到的请求页面未找到。[404]错误。当我使用下面的Url时,我能够列出存储在bucket中的图像(只是为了确保没有访问问题并且bucket名称正确)

我已经设置了标题

'Authorization' :'Bearer ' + accessToken,
'Content-Type' : contentType,
'Content-Length' : inputFile.size
请在下面找到代码片段

        $.ajax({
        url: targetUrl,
        headers: reqHeaders,
        type: 'POST',
        data: reqFormWithDataFile,
        async: false,
        cache: false,
        dataType: 'jsonp',
        useDefaultXhrHeader: false,
        processData: false,
        success: function (response) {

                alert('File Upload Successful');

        },
        error: function (jqXHR, exception) {
            var msg = '';
            if (jqXHR.status === 0) {
                msg = 'Not connect.\n Verify Network.';
            } else if (jqXHR.status == 404) {
                msg = 'Requested page not found. [404]';
            } else if (jqXHR.status == 500) {
                msg = 'Internal Server Error [500].';
            } else if (exception === 'parsererror') {
                msg = 'Requested JSON parse failed.';
            } else if (exception === 'timeout') {
                msg = 'Time out error.';
            } else if (exception === 'abort') {
                msg = 'Ajax request aborted.';
            } else {
                msg = 'Uncaught Error.\n' + jqXHR.responseText;
            }
            alert(msg);
        }
    });

我需要使用不同的URL吗?或者是否需要其他设置?请帮助。

这是正确的URL,只要您用实际的bucket名称替换
mybucket
。通读之后,我通过添加
&callback=foo
模拟了我所认为的行为,这是由于
数据类型:“jsonp'
以及
缓存:false
,通过
curl
发出了请求,并生成了具有有效回调的有效对象。您能否记录整个
jqXHR
以查看更多状态

        $.ajax({
        url: targetUrl,
        headers: reqHeaders,
        type: 'POST',
        data: reqFormWithDataFile,
        async: false,
        cache: false,
        dataType: 'jsonp',
        useDefaultXhrHeader: false,
        processData: false,
        success: function (response) {

                alert('File Upload Successful');

        },
        error: function (jqXHR, exception) {
            var msg = '';
            if (jqXHR.status === 0) {
                msg = 'Not connect.\n Verify Network.';
            } else if (jqXHR.status == 404) {
                msg = 'Requested page not found. [404]';
            } else if (jqXHR.status == 500) {
                msg = 'Internal Server Error [500].';
            } else if (exception === 'parsererror') {
                msg = 'Requested JSON parse failed.';
            } else if (exception === 'timeout') {
                msg = 'Time out error.';
            } else if (exception === 'abort') {
                msg = 'Ajax request aborted.';
            } else {
                msg = 'Uncaught Error.\n' + jqXHR.responseText;
            }
            alert(msg);
        }
    });