Hello,
I have had a lot of success so far using the HTTP endpoints to make a web app, but when I tried to switch from a regular upload to a chunked upload I've run into all sorts of problems. Primarily, it seems like I keep getting a brand new session id each time I make a request, which means that I never get a file that is more than 0 bytes. Here's what I have:
request.post('https://content.dropboxapi.com/2/files/upload_session/start', {
headers: { Authorization: 'Bearer ' + token, 'Content-Type': 'application/octet-stream'
}, body: readableStream.read(),
}, function(err, httpResponse, bodymsg,res) {
if (err) {
console.log("Error in uploading "+err);
}
if(!err) {
console.log(bodymsg);
sessionid=JSON.parse(bodymsg).session_id;
var offst=0;
readableStream.on('readable', function() {
while ((chunk=readableStream.read()) != null) {
data += chunk;
request.put('https://content.dropboxapi.com/2/files/upload_session/append_v2', {
headers: { Authorization: 'Bearer ' + token, 'Content-Type': 'application/octet-stream'
}, body: chunk,
form : {
cursor:{
session_id : sessionid,
offset : offst
}
}
}, function(err, httpResponse, bodymsg,res) {
if(err){
console.log(err)
}
console.log(httpResponse);
console.log('Made it?');
})
}
})
}
});
I know I need to have a request to end the upload, but I have not even been able to append to my upload yet. I get a session ID, but then I get a brand new one it seems during the next call. Has anyone done this or can point me towards where I can get some help?