<?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: Best Practices for Chunked Upload in Node.js in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175249#M6893</link>
    <description>&lt;P&gt;A couple other&amp;nbsp;issues I can spot:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Your code doesn't appear to ever&amp;nbsp;call /upload_session/finish. You'll need to detect&amp;nbsp;when you've&amp;nbsp;uploaded the entire file and&amp;nbsp;use that endpoint to close out the upload session.&lt;/LI&gt;
&lt;LI&gt;A while loop can't work here. You need to wait for&amp;nbsp;each call to /upload_session/append_v2 to complete before calling again. Your code kicks off a bunch of&amp;nbsp;concurrent HTTP requests, so I'd expect you to see&amp;nbsp;error responses from the server on at least some of them.&lt;/LI&gt;
&lt;LI&gt;You should be updating the value of `offset` when /upload_session/append_v2 returns. (This is part of what you'll do as you turn the while loop into a recursive call instead.)&amp;nbsp;Otherwise, all your calls to /upload_session/append_v2 will try to use the same offset, and&amp;nbsp;all but one call (the first one to make it through) will fail.&lt;/LI&gt;
&lt;LI&gt;You may also need to&amp;nbsp;put a size limit on your calls to `read`. I&amp;nbsp;believe&amp;nbsp;your current code has the potential of reading too much data and exceeding the maximum size allowed by /upload_session/start and /upload_session/append_v2.&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Sat, 09 Jul 2016 04:45:35 GMT</pubDate>
    <dc:creator>Steve M.</dc:creator>
    <dc:date>2016-07-09T04:45:35Z</dc:date>
    <item>
      <title>Best Practices for Chunked Upload in Node.js</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175245#M6889</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;PRE&gt;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?');
				})
			    }
			})
		    }
		});&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;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?&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:31:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175245#M6889</guid>
      <dc:creator>Kevin L.28</dc:creator>
      <dc:date>2019-05-29T09:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for Chunked Upload in Node.js</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175246#M6890</link>
      <description>&lt;P&gt;Can you elaborate on what you mean when you say you "get a brand new [session ID]&amp;nbsp;it seems during the next call"? Only&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start" target="_blank" rel="nofollow noreferrer"&gt;/files/upload_session/start&lt;/A&gt; returns session IDs. Can you log and share the responses you're getting?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 23:54:51 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175246#M6890</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-07-08T23:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for Chunked Upload in Node.js</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175247#M6891</link>
      <description>&lt;P&gt;When I say that, I mean that when I console.log the session ID I notice that it was changing each time and I never saw the same one twice.&lt;/P&gt;
&lt;P&gt;For example,&lt;/P&gt;
&lt;PRE&gt;AAAAAAAAGJXQJ-U67pHOfg&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 65536&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {"expires": "Sun, 10 Jul 2016 16:40:19 +0000", "upload_id": "AAAAAAAAGJXQJ-U67pHOfg", "offset": 65536}&lt;BR /&gt;[16:40:19.709Z]&amp;nbsp; INFO wt: Chunked upload called for: /tmp/get-pip.py&lt;BR /&gt;[16:40:19.709Z]&amp;nbsp; INFO wt: &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AAAAAAAAGJkcP0WgJC2wAQ&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16384&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {"expires": "Sun, 10 Jul 2016 16:40:19 +0000", "upload_id": "AAAAAAAAGJkcP0WgJC2wAQ", "offset": 16384}&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;What I realized was that my chunkedUpload() function was being called over and over again for some unknown reason, and that I was actually getting correct files in my Dropbox so long as they were small enough to fit in a single chunk, so I believe my code is likely mostly correct here but the problem is external to the upload function.&lt;/P&gt;
&lt;P&gt;Thus it makes sense why I was getting more than one ID, the upload_session/start endpoint is getting hit multiple times and I need to find a way in my code to make sure it only attempts this once per file.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jul 2016 00:00:09 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175247#M6891</guid>
      <dc:creator>Kevin L.28</dc:creator>
      <dc:date>2016-07-09T00:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for Chunked Upload in Node.js</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175248#M6892</link>
      <description>&lt;P&gt;I see, yes, only the start endpoint gives you a new session ID, so it does look like your method is getting called more than once. You only need to call successfully start once per file though.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're having trouble with the API once you sort that part out, let us know.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jul 2016 02:43:07 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175248#M6892</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-07-09T02:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices for Chunked Upload in Node.js</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175249#M6893</link>
      <description>&lt;P&gt;A couple other&amp;nbsp;issues I can spot:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Your code doesn't appear to ever&amp;nbsp;call /upload_session/finish. You'll need to detect&amp;nbsp;when you've&amp;nbsp;uploaded the entire file and&amp;nbsp;use that endpoint to close out the upload session.&lt;/LI&gt;
&lt;LI&gt;A while loop can't work here. You need to wait for&amp;nbsp;each call to /upload_session/append_v2 to complete before calling again. Your code kicks off a bunch of&amp;nbsp;concurrent HTTP requests, so I'd expect you to see&amp;nbsp;error responses from the server on at least some of them.&lt;/LI&gt;
&lt;LI&gt;You should be updating the value of `offset` when /upload_session/append_v2 returns. (This is part of what you'll do as you turn the while loop into a recursive call instead.)&amp;nbsp;Otherwise, all your calls to /upload_session/append_v2 will try to use the same offset, and&amp;nbsp;all but one call (the first one to make it through) will fail.&lt;/LI&gt;
&lt;LI&gt;You may also need to&amp;nbsp;put a size limit on your calls to `read`. I&amp;nbsp;believe&amp;nbsp;your current code has the potential of reading too much data and exceeding the maximum size allowed by /upload_session/start and /upload_session/append_v2.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sat, 09 Jul 2016 04:45:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Best-Practices-for-Chunked-Upload-in-Node-js/m-p/175249#M6893</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2016-07-09T04:45:35Z</dc:date>
    </item>
  </channel>
</rss>

