<?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: no longer able to upload video via api in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/no-longer-able-to-upload-video-via-api/m-p/535770#M25783</link>
    <description>&lt;P&gt;Thanks, you clued me into a bug that got into my code. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@FBF7D2AB59A0D6E861EBF6A36F93B7E2/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jul 2021 19:16:44 GMT</pubDate>
    <dc:creator>tiamat</dc:creator>
    <dc:date>2021-07-28T19:16:44Z</dc:date>
    <item>
      <title>no longer able to upload video via api</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/no-longer-able-to-upload-video-via-api/m-p/535561#M25774</link>
      <description>&lt;P&gt;The following code once successfully uploaded video, but now does not. No errors thrown on execution of the &lt;STRONG&gt;&lt;EM&gt;upload()&lt;/EM&gt;&lt;/STRONG&gt; function and I get 200 a response back from the server for each chunk read from the file. I wonder if there is something wrong with my account - I got a warning to renew and afterwards I started having issues?&amp;nbsp; Thanks much for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;const fs = require('fs');
const path = require('path');
const { dbx } = require('../dropbox/dbx');
const MAX_RETRIES = 100;
const CHUNK_SIZE = 10485760;

const uploadBigFile = async (localPath, uploadPath, size) =&amp;gt; {
  const stream = fs.createReadStream(localPath, {
    highWaterMark: CHUNK_SIZE,
  });
  let chunkNumber = 0;
  let offset = 0;
  let session_id;

  for await (let chunk of stream) {
    if (!chunkNumber++) {
      const { result } = await dbx.filesUploadSessionStart({
        contents: chunk,
      });
      session_id = result.session_id;
    } else if (offset + chunk.length === size) {
      await dbx.filesUploadSessionFinish({
        contents: chunk,
        cursor: { session_id, offset },
        commit: {
          path: uploadPath,
          mode: 'overwrite',
          client_modified: date,
        },
      });
    } else {
      await dbx.filesUploadSessionAppendV2({
        contents: chunk,
        cursor: { offset, session_id },
        close: false,
      });
    }
    offset += chunk.length;
  }
};

const upload = ({ futureDropboxFileName, date }) =&amp;gt; {
  return new Promise(async (resolve, reject) =&amp;gt; {
    async function doUpload(futureDropboxFileName, date, photo, retries = 0) {
      const dropboxPath = `${process.env.DROPBOX_FOLDER}${futureDropboxFileName}`;
      const convertedPath = path.join(__dirname, '/tmp/', futureDropboxFileName);
      
      try {
        const { size } = fs.statSync(convertedPath);
        await uploadBigFile(convertedPath, dropboxPath, date, size);
        resolve('ok');
      } catch (error) {
        if (retries &amp;lt;= MAX_RETRIES) {
          doUpload(futureDropboxFileName, date, photo, retries + 1);
        } else {
          return reject(error);
        }
      }
    }
    return doUpload(futureDropboxFileName, date, photo);
  });
};&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 21:14:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/no-longer-able-to-upload-video-via-api/m-p/535561#M25774</guid>
      <dc:creator>tiamat</dc:creator>
      <dc:date>2021-07-27T21:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: no longer able to upload video via api</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/no-longer-able-to-upload-video-via-api/m-p/535703#M25781</link>
      <description>&lt;P&gt;Can you print out the result of filesUploadSessionFinish? If no exceptions are being thrown, that should be returning the metadata of the uploaded file.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 14:39:40 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/no-longer-able-to-upload-video-via-api/m-p/535703#M25781</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2021-07-28T14:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: no longer able to upload video via api</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/no-longer-able-to-upload-video-via-api/m-p/535770#M25783</link>
      <description>&lt;P&gt;Thanks, you clued me into a bug that got into my code. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@FBF7D2AB59A0D6E861EBF6A36F93B7E2/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 19:16:44 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/no-longer-able-to-upload-video-via-api/m-p/535770#M25783</guid>
      <dc:creator>tiamat</dc:creator>
      <dc:date>2021-07-28T19:16:44Z</dc:date>
    </item>
  </channel>
</rss>

