Google Cloud Storage File Upload - Requested page not found. [404] -
i trying upload file google cloud storage using json api. posting request below url file attachment.
https://www.googleapis.com/upload/storage/v1/b/mybucket/o?uploadtype=media&name=solarsystemlrg.png but getting requested page not found. [404] error. when use below url, able list images stored in bucket (just sure there no access issues , bucket name correct).
https://www.googleapis.com/storage/v1/b/mybucket/o i have set headers.
'authorization' :'bearer ' + accesstoken, 'content-type' : contenttype, 'content-length' : inputfile.size please find code snippet below.
$.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); } }); do need use different url? or there other setting required? please help.
that's right url, long replace mybucket actual bucket name. after reading through jquery.ajax(), emulated think behavior adding &callback=foo, due datatype: 'jsonp' , &_=1474410231688 because cache: false, , issued request via curl , produced valid object valid callback. can log entire jqxhr see more of status?
Comments
Post a Comment