<?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: How to know the offset for filesUploadSessionFinishBatch() in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-know-the-offset-for-filesUploadSessionFinishBatch/m-p/350538#M617</link>
    <description>&lt;P&gt;You should keep track of the offset client-side, while uploading the data, so that you can specify the value when sending the next piece of the file, or when finishing the file. There's &lt;A href="https://github.com/dropbox/dropbox-sdk-js/blob/master/examples/javascript/upload/index.html#L63" target="_self"&gt;a sample implementation here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;It looks like your usage is a little different though, in that you're not using&amp;nbsp;filesUploadSessionAppendV2. It sounds like your files are small enough that you can upload all of the data with a single call to&amp;nbsp;filesUploadSessionStart each. In this case, that means that your "offset" would just be the length of the file data.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jun 2019 15:35:36 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2019-06-17T15:35:36Z</dc:date>
    <item>
      <title>How to know the offset for filesUploadSessionFinishBatch()</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-know-the-offset-for-filesUploadSessionFinishBatch/m-p/350319#M616</link>
      <description>&lt;P&gt;Hi, I am trying to upload many files using the JavaScript SDK's&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;filesUploadSessionFinishBatch(),&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;For that, I am looping through all the files and calling&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;filesUploadSessionStart() for each file.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Things are fine up to this point, but I am wondering How am I supposed to know the value of cursor.offset before getting the&amp;nbsp;lookup_failed error.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Here's my code&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;const uploadImagesToDropbox = async (team_member_id, dbxUser, clientFolder) =&amp;gt; {
	try{
		const queueData = await uploadQueue.find({team_member_id, status: 2})
		const appDir = path.dirname(require.main.filename);
		const printResPath = `${clientFolder}/Print Resolution`;
		const webResPath = `${clientFolder}/Web Resolution`;
		const isPrintResPathExists = await dbxFolderExists(dbxUser, printResPath);
		const isWebResPathExists = await dbxFolderExists(dbxUser, webResPath);
		!isPrintResPathExists &amp;amp;&amp;amp; await dbxUser.filesCreateFolderV2({path: printResPath})
		!isWebResPathExists &amp;amp;&amp;amp; await dbxUser.filesCreateFolderV2({path: webResPath});
		const batchData= [];
		for(let data of queueData){
			let PrintResFilePath = `${appDir}${data.destination.split("/").join("\\")}\\${data.filename}`;
			let WebResFilePath = `${appDir}${data.destination.split("/").join("\\")}\\Web_Resolution\\${data.filename}`;
			let PrintResFile = fs.readFileSync(PrintResFilePath)
			let WebResFile = fs.readFileSync(WebResFilePath)
			const printResStart = await dbxUser.filesUploadSessionStart({ contents: PrintResFile, close: true})
			const webResStart = await dbxUser.filesUploadSessionStart({ contents: WebResFile, close: true})
			batchData.push({
				cursor:{
					session_id: printResStart.session_id,
					offset: 0 //&amp;lt;--- What should I pass Here?
				},
				commit: {
					path: printResPath
				}
			})

			batchData.push({
				cursor:{
					session_id: webResStart.session_id,
					offset: 0 //&amp;lt;--- What should I pass Here?
				},
				commit: {
					path: webResPath
				}
			})
			console.log(data.filename, "Uploaded")
		}console.log(batchData)
		const res = await dbxUser.filesUploadSessionFinishBatch({ entries: batchData });
		console.log(res)
		const status = await dbxUser.filesUploadSessionFinishBatchCheck({async_job_id: res.async_job_id})
		console.log(JSON.stringify(status))
		let interval = setInterval(async () =&amp;gt; {
			const status = await dbxUser.filesUploadSessionFinishBatchCheck({async_job_id: res.async_job_id})
			status['.tag'] === "complete" &amp;amp;&amp;amp; clearInterval(interval)
			console.log(JSON.stringify(status))
		}, 10000);
		
		await uploadQueue.deleteMany({team_member_id})
		rimraf.sync(`${appDir}\\uploads\\${team_member_id.replace(":", "_")}`)
	} catch(error){
		console.log(error)
		return error;
	}
}&lt;/PRE&gt;
Currently, this code throws the following error&lt;/DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;{
  ".tag": "complete",
  "entries": [
    {
      ".tag": "failure",
      "failure": {
        ".tag": "lookup_failed",
        "lookup_failed": {
          ".tag": "incorrect_offset",
          "correct_offset": 11721555
        }
      }
    },
    {
      ".tag": "failure",
      "failure": {
        ".tag": "lookup_failed",
        "lookup_failed": {
          ".tag": "incorrect_offset",
          "correct_offset": 3529761
        }
      }
    },
    {
      ".tag": "failure",
      "failure": {
        ".tag": "lookup_failed",
        "lookup_failed": {
          ".tag": "incorrect_offset",
          "correct_offset": 8843127
        }
      }
    },
    {
      ".tag": "failure",
      "failure": {
        ".tag": "lookup_failed",
        "lookup_failed": {
          ".tag": "incorrect_offset",
          "correct_offset": 2877230
        }
      }
    },
    {
      ".tag": "failure",
      "failure": {
        ".tag": "lookup_failed",
        "lookup_failed": {
          ".tag": "incorrect_offset",
          "correct_offset": 10066923
        }
      }
    },
    {
      ".tag": "failure",
      "failure": {
        ".tag": "lookup_failed",
        "lookup_failed": {
          ".tag": "incorrect_offset",
          "correct_offset": 3037603
        }
      }
    }
  ]
}&lt;/PRE&gt;
I know there's a&amp;nbsp;correct_offset value, but I received it after calling
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;filesUploadSessionFinishBatchCheck&lt;/SPAN&gt;&lt;SPAN&gt;(). However, this is something that I should know before calling the&amp;nbsp;&lt;SPAN&gt;filesUploadSessionFinishBatchCheck() so that I can pass it down&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 16 Jul 2019 09:48:15 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-know-the-offset-for-filesUploadSessionFinishBatch/m-p/350319#M616</guid>
      <dc:creator>zainulabd786</dc:creator>
      <dc:date>2019-07-16T09:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to know the offset for filesUploadSessionFinishBatch()</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-know-the-offset-for-filesUploadSessionFinishBatch/m-p/350538#M617</link>
      <description>&lt;P&gt;You should keep track of the offset client-side, while uploading the data, so that you can specify the value when sending the next piece of the file, or when finishing the file. There's &lt;A href="https://github.com/dropbox/dropbox-sdk-js/blob/master/examples/javascript/upload/index.html#L63" target="_self"&gt;a sample implementation here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;It looks like your usage is a little different though, in that you're not using&amp;nbsp;filesUploadSessionAppendV2. It sounds like your files are small enough that you can upload all of the data with a single call to&amp;nbsp;filesUploadSessionStart each. In this case, that means that your "offset" would just be the length of the file data.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 15:35:36 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-know-the-offset-for-filesUploadSessionFinishBatch/m-p/350538#M617</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2019-06-17T15:35:36Z</dc:date>
    </item>
  </channel>
</rss>

