<?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: File uploading slow in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-uploading-slow/m-p/448808#M23356</link>
    <description>&lt;P&gt;There are a number of variables that will affect overall performance of transfers like this, some of which can't be controlled unfortunately. There are some other options that may be helpful though, depending on the specifics of your scenario.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the files do already exist in the&amp;nbsp;Dropbox account and you just need to make copies of them, using&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCopyBatchV2__anchor" target="_self"&gt;filesCopyBatchV2&lt;/A&gt; may be faster.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, if the files already exist in another&amp;nbsp;Dropbox account, and you have authorization to both of them, you may want to try using&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCopyReferenceGet__anchor" target="_self"&gt;filesCopyReferenceGet&lt;/A&gt; and&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCopyReferenceSave__anchor" target="_self"&gt;filesCopyReferenceSave&lt;/A&gt; instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, if you have a significant number of files to upload, you may want to use the "Batch Upload" method described in &lt;A href="https://www.dropbox.com/lp/developers/reference/dbx-performance-guide" target="_self"&gt;the Performance Guide&lt;/A&gt;. That way, you can upload the file data for several files at a time in parallel, using&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionStart__anchor" target="_self"&gt;filesUploadSessionStart&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionAppendV2__anchor" target="_self"&gt;filesUploadSessionAppendV2&lt;/A&gt; as needed, and then commit them all at once when those are done using&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionFinishBatch__anchor" target="_self"&gt;filesUploadSessionFinishBatch&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Aug 2020 15:46:13 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2020-08-27T15:46:13Z</dc:date>
    <item>
      <title>File uploading slow</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-uploading-slow/m-p/448770#M23352</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using the javscript sdk, and trying to upload multiple files (one after another) with dbx.filesUpload. Due to the nature of my projectm I have to upload multiple files when the user sends a request. Each file is taking around a second, which results in long waiting times for the user when they need, say, 50 files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code:&lt;/P&gt;
&lt;PRE&gt;async function uploadMultipleFiles (storageFilePaths,packFilePaths,packRoot) {
	try {
		for (i in storageFilePaths) {
			console.log(await dbx.filesUpload({ path: packRoot+packFilePaths[i], contents: fs.readFileSync(storageFilePaths[i])}))
		}
	} catch (err) {
		throw err
	}
}&lt;/PRE&gt;
&lt;P&gt;Full code is &lt;A href="https://github.com/Beatso1/littleimprovements-custom/blob/master/app.js" target="_blank" rel="noopener"&gt;here&lt;/A&gt;. I have to use await; see &lt;A href="https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/too-many-requests-when-uploading-multiple-files/m-p/447951" target="_blank" rel="noopener"&gt;this thread&lt;/A&gt;. Would there be a quicker way to do this without getting too many requests? Would it be quicker to copy the files from another place in my dropbox rather than upload them like this?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 13:58:06 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-uploading-slow/m-p/448770#M23352</guid>
      <dc:creator>Beatso</dc:creator>
      <dc:date>2020-08-27T13:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: File uploading slow</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-uploading-slow/m-p/448808#M23356</link>
      <description>&lt;P&gt;There are a number of variables that will affect overall performance of transfers like this, some of which can't be controlled unfortunately. There are some other options that may be helpful though, depending on the specifics of your scenario.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the files do already exist in the&amp;nbsp;Dropbox account and you just need to make copies of them, using&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCopyBatchV2__anchor" target="_self"&gt;filesCopyBatchV2&lt;/A&gt; may be faster.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, if the files already exist in another&amp;nbsp;Dropbox account, and you have authorization to both of them, you may want to try using&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCopyReferenceGet__anchor" target="_self"&gt;filesCopyReferenceGet&lt;/A&gt; and&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCopyReferenceSave__anchor" target="_self"&gt;filesCopyReferenceSave&lt;/A&gt; instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, if you have a significant number of files to upload, you may want to use the "Batch Upload" method described in &lt;A href="https://www.dropbox.com/lp/developers/reference/dbx-performance-guide" target="_self"&gt;the Performance Guide&lt;/A&gt;. That way, you can upload the file data for several files at a time in parallel, using&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionStart__anchor" target="_self"&gt;filesUploadSessionStart&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionAppendV2__anchor" target="_self"&gt;filesUploadSessionAppendV2&lt;/A&gt; as needed, and then commit them all at once when those are done using&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionFinishBatch__anchor" target="_self"&gt;filesUploadSessionFinishBatch&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 15:46:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-uploading-slow/m-p/448808#M23356</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-08-27T15:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: File uploading slow</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-uploading-slow/m-p/449198#M23365</link>
      <description>&lt;P&gt;Thanks for your help. &lt;STRIKE&gt;Using the batch upload method, how to I "group files that are being uploaded into one or more batches"? Also, do I use filesUploadSessionStart for each file, or do I use it once, and append for every other file? Is there anywhere where I could find an example of uploading multiple files with a batch upload?&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;Edit: I found your example &lt;A href="https://github.com/dropbox/dropbox-sdk-js/issues/80#issuecomment-283189888" target="_blank" rel="noopener"&gt;here&lt;/A&gt;. My code is as follows:&lt;/STRIKE&gt;&lt;/P&gt;&lt;PRE&gt;&lt;STRIKE&gt;var entries = []
for (i in storageFilePathsToUpload) {
	let fileData = fs.readFileSync(storageFilePathsToUpload[i])
	dbx.filesUploadSessionStart({
		contents: fileData,
		close: true,
	})
	.then(function (response) {
		entries.push({cursor:{session_id:response.session_id,offset:fileData.length},commit:{path:packPath+packFilePathsToUpload[i]}})
		console.log("entriesinprog")
	})
	.catch(function (err) {
		console.log(err);
	});
}

console.log(entries)
dbx.filesUploadSessionFinishBatch({entries:entries})
.then(function(response){
	dbx.filesUploadSessionFinishBatchCheck({async_job_id: response.async_job_id})
	.then(function(response){
		console.log(response)
	})
	.catch(function(err){
		console.log(err)
	})

	}).catch(err =&amp;gt; {
		console.log(err)
	})&lt;/STRIKE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRIKE&gt;It's not working because it's not executing in the right order. The filesUploadSessionFinishBatchCheck is logging its response before the filesUploadSessionStart has finished uploading. Why is this, and how could I only finish the batch once the for loop has finished? (I'm not in an async function). It might sort of relate to &lt;A href="https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Create-sharing-link-after-file-upload/m-p/447009" target="_blank" rel="noopener"&gt;this&lt;/A&gt; thread, but I obviously can't use .then on a for loop.&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;Thanks once again for your help.&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit 2: I got the above working, and now my code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;async function startSessions () {
	entries = []
	for (let [index,val] of storageFilePathsToUpload.entries()) {
		let fileData = fs.readFileSync(val)
		await dbx.filesUploadSessionStart({
			contents: fileData,
			close: true,
		})
		.then(function (response) {
			entries.push({cursor:{session_id:response.session_id,offset:fileData.length},commit:{path:packPath+packFilePathsToUpload[index]}})
		})
		.catch(function (err) {
			console.error(err)
		})
	}
}


startSessions().then(()=&amp;gt;{
	console.log(entries)
	dbx.filesUploadSessionFinishBatch({entries:entries})
	.then(function(response){
		dbx.filesUploadSessionFinishBatchCheck({async_job_id: response.async_job_id})
		.then(function(output){
			console.log(output) // THIS RETURNS { '.tag': 'in_progress' }
			// get share link and send it
			getShareLink("/test").then((response)=&amp;gt;{res.send(response)}).catch((error)=&amp;gt;{res.send("error");console.error(error)})
		})
		.catch(function(err){
			console.error(err)
		})
	}).catch(err =&amp;gt; {
		console.error(err)
	})
	
}).catch((err)=&amp;gt;{console.error(err)})&lt;/PRE&gt;&lt;P&gt;When the output of filesUploadSessionFinishBatchCheck is logged, it gives { '.tag': 'in_progress' }. Is there a way to not run the code until the batch is finished?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Aug 2020 13:09:49 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-uploading-slow/m-p/449198#M23365</guid>
      <dc:creator>Beatso</dc:creator>
      <dc:date>2020-08-30T13:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: File uploading slow</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-uploading-slow/m-p/449655#M23375</link>
      <description>&lt;P&gt;Your app needs to call&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionFinishBatchCheck__anchor" target="_self"&gt;filesUploadSessionFinishBatchCheck&lt;/A&gt; occasionally to determine when the batch has finished, and only then proceed with whatever other operations it needs to run based on the result (similar to your other thread, except that you may need to call a few times). That batch operation is happening on the&amp;nbsp;Dropbox servers, so your app won't know by itself when that's done without checking with the servers via that method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you should have your app poll &lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionFinishBatchCheck__anchor" target="_self"&gt;filesUploadSessionFinishBatchCheck&lt;/A&gt; occasionally, say, every few seconds, until&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/global.html#FilesUploadSessionFinishBatchJobStatus" target="_self"&gt;FilesUploadSessionFinishBatchJobStatus&lt;/A&gt; is no longer 'in_progress'. Then you can check the&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/global.html#FilesUploadSessionFinishBatchResult" target="_self"&gt;FilesUploadSessionFinishBatchResult&lt;/A&gt; in&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/global.html#FilesUploadSessionFinishBatchJobStatus" target="_self"&gt;FilesUploadSessionFinishBatchJobStatus&lt;/A&gt;.complete to see the results and continue from there.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 14:52:55 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/File-uploading-slow/m-p/449655#M23375</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-08-31T14:52:55Z</dc:date>
    </item>
  </channel>
</rss>

