OneDrive Upload API, resumeable uploading does not work on web -
i have developed web apps. http://onedrive.booogle.net/
the resumeable uploading onedrive api not work on web. simple item uploading works (100m limit). "request header field content-range not allowed access-control-allow-headers."
error occurs on chrome, firefox... bugs? how fix it?
function _upload_send(uploadurl){ var cfiledata='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; var body=btoa(cfiledata); var start=0; var end=cfiledata.length; var len=cfiledata.length; xhr.open('put', uploadurl); xhr.setrequestheader('authorization', 'bearer ' + md_access_token); xhr.setrequestheader('content-range', 'bytes '+start+'-'+(end-1)+'/'+len); xhr.setrequestheader('content-encoding', 'base64'); xhr.onload = function(){ //request header field content-range not allowed access-control-allow-headers. }; xhr.onerror = function(e){ //request header field content-range not allowed access-control-allow-headers. }; xhr.send(body); } function _upload_create(){ filename='largefile.txt'; xhr.open('post', 'https://api.onedrive.com/v1.0'+'/drive/items/'+upload_id+':/'+encodeuricomponent(filename)+':/upload.createsession'); xhr.setrequestheader('authorization', 'bearer ' + md_access_token); xhr.setrequestheader('content-type', 'application/json'); var body={ "item": { "@name.conflictbehavior": "rename", "name": filename } }; xhr.onload = function(){ if(this.status==200){ try{ var a=json.parse(this.response); if(a.uploadurl){ _upload_send(a.uploadurl); } }catch(err){} } }; xhr.onerror = function(e){ }; xhr.send(json.stringify(body)); }
this bug. reporting it. tracking https://github.com/onedrive/onedrive-api-docs/issues/157. we'll fix soon.
-- update --
this fixed.
Comments
Post a Comment