<?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: filesUpload gives corrupted file in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/filesUpload-gives-corrupted-file/m-p/285585#M17501</link>
    <description>That was it! Thanks!&lt;BR /&gt;&lt;BR /&gt;Stupid that i just tried the two options and not the third option..</description>
    <pubDate>Fri, 20 Jul 2018 16:16:30 GMT</pubDate>
    <dc:creator>Sega</dc:creator>
    <dc:date>2018-07-20T16:16:30Z</dc:date>
    <item>
      <title>filesUpload gives corrupted file</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/filesUpload-gives-corrupted-file/m-p/285522#M17492</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm want to use the Dropbox API/SDK in one of my projects. I have to convert a base64 string I'm getting from my webcam as a screenshot into a real image and then upload it to Dropbox. (I'm more a Designer than a coder, so if I mismatch something - sorry for that.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following the code I'm currently using:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;const base64File = this.webcam.getScreenshot()
const dbx = new Dropbox({ accessToken: this.state.dropboxToken })
const i = base64File.indexOf('base64,')
const buffer = Buffer.from(base64File.slice(i + 7), 'base64')
const name = 'test.png'
const file = new File(buffer, name, { type: 'image/png'})
dbx.filesUpload({path: '/' + file.name, contents: file})
.then(function (response) {
    console.log(response)
})
.catch(function (error) {
    console.error('dropbox error', error)
})&lt;/PRE&gt;&lt;P&gt;Right now, I'm getting a .png file with 1.2 MByte size but I can't open it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I'm using "file.buffer" in "contents" in the filesUpload function I'm getting a zero size file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm glad for every help I can get. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:11:48 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/filesUpload-gives-corrupted-file/m-p/285522#M17492</guid>
      <dc:creator>Sega</dc:creator>
      <dc:date>2019-05-29T09:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: filesUpload gives corrupted file</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/filesUpload-gives-corrupted-file/m-p/285573#M17498</link>
      <description>&lt;P&gt;I believe you should just supply the buffer directly, so all you need to do is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;const base64File = this.webcam.getScreenshot()
const dbx = new Dropbox({ accessToken: this.state.dropboxToken })
const i = base64File.indexOf('base64,')
const buffer = Buffer.from(base64File.slice(i + 7), 'base64')
const name = 'test.png'

dbx.filesUpload({path: '/' + name, contents: buffer})
.then(function (response) {
    console.log(response)
})
.catch(function (error) {
    console.error('dropbox error', error)
})&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 14:48:45 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/filesUpload-gives-corrupted-file/m-p/285573#M17498</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-07-20T14:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: filesUpload gives corrupted file</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/filesUpload-gives-corrupted-file/m-p/285585#M17501</link>
      <description>That was it! Thanks!&lt;BR /&gt;&lt;BR /&gt;Stupid that i just tried the two options and not the third option..</description>
      <pubDate>Fri, 20 Jul 2018 16:16:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/filesUpload-gives-corrupted-file/m-p/285585#M17501</guid>
      <dc:creator>Sega</dc:creator>
      <dc:date>2018-07-20T16:16:30Z</dc:date>
    </item>
  </channel>
</rss>

