Hey,
I'm working on a dropbox upload function in java (coldfusion). The simpel upload works perfectly, but I'm having troubles with the session upload. Here is what I try to do:
>I have an image (20 MB)
>I start the session and add the first chunk (chunks of 4 MB = 4194304 KB)
>The first append I call after the start session returns a 409 error
The weird part is the following: on the start I already sent the first chunk of 4MB. So I guess that the first append should have an offset of 4MB. The funny thing is that the error states that I should have a offset of 8024827KB.
I have no idea where dropbox gets this number from. And when I follow this for all the chunks then I get a corrupted file of 40MB.
Is this logic wrong? If you want to see some code I could do that, but I don't think that's it.
Also the weird part is, is when I do chunks of 150 MB (so it skips the append) then it works perfectly...
It seems that the append doesn't correctly handle the offset.
Thanks in advance!
P.S. here is the append code:
var used_offset = (loop_counter - 1) * max_chunk_size;
var stuResponse = {};
var httpService = new http();
httpService.setMethod("POST");
httpService.setCharset("utf-8");
httpService.setUrl("https://content.dropboxapi.com/2/files/upload_session/append_v2");
httpService.addParam(type="header", name="Authorization", value="Bearer #gebruikte_token#");
httpService.addParam(type="header", name="Dropbox-API-Arg", value="#serializeJSON({
"cursor" : {
"session_id" : upload_doc_session,
"offset" : used_offset
},
"close" : close_con
})#");
httpService.addParam(type="header", name="Content-type", value="application/octet-stream");
httpService.addParam(type="body", value="#chunk#");
var result = httpService.send().getPrefix();
if(structKeyExists(result.ResponseHeader, 'Status_Code') && result.ResponseHeader['Status_Code'] eq '200'){
}
else{
return ["ERROR", "2 GET: URL geeft een fout. Code: #result.Statuscode# - #result['status_text']# - #result['errordetail']#", result, used_offset, close_con];
}