My problem was that I couldn´t upload files bigger than 4MB so I used the createuploadsession according to createuploadsession
I successfully get the uploadUrl value from the createuploadsession response. Now I try to make a PUT request with this code
var file = 'C:\\files\\box.zip'
fs.readFile(file, function read(e, f) {
request.put({
url: 'https://api.onedrive.com/rup/545d583xxxxxxxxxxxxxxxxxxxxxxxxx',
headers: {
'Content-Type': mime.lookup(file),
'Content-Length': f.length,
'Content-Range': 'bytes ' + f.length
}
}, function(er, re, bo) {
console.log('#324324', bo);
});
});
But I will get as response "Invalid Content-Range header value" also if I would try
'Content-Range': 'bytes 0-' + f.length
//or
'Content-Range': 'bytes 0-' + f.length + '/' + f.length
I will get the same response.
Also I don´t want to chunk my file I just want to upload my file complete in 1run. Does anybody have sample code for upload a file to the uploadUrl from the createuploadsession response. Also do I really need to get first this uploadurl before i can upload files bigger than 4mb or is there an alternative way?
How about following sample script?
The flow of this script is as follows.
The detail information is https://dev.onedrive.com/items/upload_large_files.htm.
Sample script :
In my environment, this works fine. I could upload a 100 MB file to OneDrive using this script. If this doesn't work at your environment, feel free to tell me.