<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dropbox upload session append - incorrect offset in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482569#M24308</link>
    <description>&lt;P&gt;Thanks for following up. I'm glad to hear you already sorted this out. (Your other message got caught in the spam filter for some reason. I've restored it.)&lt;/P&gt;</description>
    <pubDate>Mon, 28 Dec 2020 18:06:38 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2020-12-28T18:06:38Z</dc:date>
    <item>
      <title>Dropbox upload session append - incorrect offset</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482496#M24301</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;I have an image (20 MB)&lt;/P&gt;&lt;P&gt;&amp;gt;I start the session and add the first chunk (chunks of 4 MB =&amp;nbsp;&lt;SPAN&gt;4194304 KB)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;The first append I call after the start session returns a 409 error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&amp;nbsp;&lt;SPAN&gt;8024827KB.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is this logic wrong? If you want to see some code I could do that, but I don't think that's it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also the weird part is, is when I do chunks of 150 MB (so it skips the append) then it works perfectly...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It seems that the append doesn't correctly handle the offset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;P.S. here is the append code:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;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') &amp;amp;&amp;amp; 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];
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Dec 2020 14:24:39 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482496#M24301</guid>
      <dc:creator>DrunkenMoose</dc:creator>
      <dc:date>2020-12-28T14:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox upload session append - incorrect offset</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482537#M24305</link>
      <description>&lt;P&gt;If the first /2/files/upload_session/append_v2 call is failing with 'incorrect_offset', and indicating a 'correct_offset' of&amp;nbsp;8024827 for that upload session, then that indicates that the API received that much data for that upload session in the&amp;nbsp;/2/files/upload_session/start call. That is, the 'correct_offset' value indicates how much data the API has&amp;nbsp;received so far for that upload session. If this number is higher than expected, it's likely that your code is accidentally sending more data per call than you intended.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;recommend debugging your code for calling&amp;nbsp;/2/files/upload_session/start to make sure you're only sending as much data as you intended, i.e., "4194304 KB" in this case, from your description. (By the way, did you mean&amp;nbsp;bytes instead of KB?&amp;nbsp;&lt;SPAN&gt;4 MB =&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;4194304 bytes, not KB.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also, it makes sense that it would work if you use a chunk size of 150 MB for a 20 MB file, since you would be uploading the entire file in the&amp;nbsp;/2/files/upload_session/start call, and so wouldn't need to use&amp;nbsp;/2/files/upload_session/append_v2, so the offset value doesn't need to be checked.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 16:03:12 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482537#M24305</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-12-28T16:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox upload session append - incorrect offset</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482546#M24306</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, thanks for the quick response! Well that's what I thought! The error indeed states that the first call supposetly sends 8mb data. I made another test example, which is more simple, and I still get the same error. And when I dump the first chunk, it says it's 4mb.. here look at this (I removed unnecessary code):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var max_chunk_size = 4 * 1024 * 1024;&lt;BR /&gt;var stuResponse = {};
var httpService = new http();
httpService.setUrl("https://content.dropboxapi.com/2/files/upload_session/start");
httpService.addParam(type="header", name="Dropbox-API-Arg", value="#serializeJSON({
  "close" : false
})#");
httpService.addParam(type="body", value="#all_chunks[1]#");
var result = httpService.send().getPrefix();

if(structKeyExists(result.ResponseHeader, 'Status_Code') &amp;amp;&amp;amp; result.ResponseHeader['Status_Code'] eq '200'){
  upload_doc_session = deserializeJSON(result['filecontent'])['session_id'];
}&lt;BR /&gt;
var stuResponse = {};
var httpService = new http();
httpService.setUrl("https://content.dropboxapi.com/2/files/upload_session/append_v2");
httpService.addParam(type="header", name="Dropbox-API-Arg", value="#serializeJSON({
  "cursor" : {
    "session_id" : upload_doc_session,
  "offset" : max_chunk_size
},
  "close" : false
})#");
httpService.addParam(type="body", value="");
var result = httpService.send().getPrefix();

if(structKeyExists(result.ResponseHeader, 'Status_Code') &amp;amp;&amp;amp; result.ResponseHeader['Status_Code'] eq '200'){

}
else{
  here I get a 409 error that the first call is 8mb big.
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I dump "all_chunks[1]" it says it's 4mb length. Am I going a little mad here or am I just missing something?&lt;/P&gt;&lt;P&gt;The weird part is that when I do a test with i.e. the string "test" in the first start session, then I correctly get the error&lt;/P&gt;&lt;P&gt;that the last call was 4 bytes long. So I think maybe it's actually 8mb, but the java function len() gives 4mb...&lt;/P&gt;&lt;P&gt;but that would be so weird.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 16:41:53 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482546#M24306</guid>
      <dc:creator>DrunkenMoose</dc:creator>
      <dc:date>2020-12-28T16:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox upload session append - incorrect offset</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482558#M24307</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I posted a whole reply, but it get removed? But now I see that len(chunk) does not represent the correct bit length.&lt;/P&gt;&lt;P&gt;You actually have to put the chunks in a&amp;nbsp;ByteBuffer to correctly split it in the 4mb chunks. Weird how len(chunk)&lt;/P&gt;&lt;P&gt;is exatly devided by 2, somehow this is actually 8mb. But thanks for the reply and the info! Now it's working great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;Moose&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 17:20:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482558#M24307</guid>
      <dc:creator>DrunkenMoose</dc:creator>
      <dc:date>2020-12-28T17:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox upload session append - incorrect offset</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482569#M24308</link>
      <description>&lt;P&gt;Thanks for following up. I'm glad to hear you already sorted this out. (Your other message got caught in the spam filter for some reason. I've restored it.)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 18:06:38 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-upload-session-append-incorrect-offset/m-p/482569#M24308</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-12-28T18:06:38Z</dc:date>
    </item>
  </channel>
</rss>

