<?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: Upload PDF files/proper encoding in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/334643#M19523</link>
    <description>Any update on this situation. I am having a similar problem. Unfortunately, in my senecio i can not controll the source of the PDF. Is there a way to not get a corroupted off out of the api the the same file is fine out of the web UI?</description>
    <pubDate>Tue, 19 Mar 2019 13:22:51 GMT</pubDate>
    <dc:creator>Psome</dc:creator>
    <dc:date>2019-03-19T13:22:51Z</dc:date>
    <item>
      <title>Upload PDF files/proper encoding</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/266409#M15630</link>
      <description>&lt;P&gt;I have a simple Python Flask application that allows users to upload PDF files to a Dropbox account. I am able to successfully upload the file to Dropbox, as well as go directly go to dropbox.com and download the file. But when I try to open the file I just downloaded from dropbox.com directly it mentions that the file is corrupted/not correctly encoded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to file uploads in general, what is the best practice to encoding PDF files and storing them on Dropbox?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I use to upload the PDF files:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    def upload_to_dbx(self):
        # read in the file as binary
        with open(os.path.join('uploaded_forms', self.uploaded_filename), 'rb') as f:
            read_file = f.read()

        # path wher the uploaded file will be stored in Dropbox
        user_filepath_name = '/{fname} {lname}/{filename}'.format(fname=self.user.first_name,
                                                                  lname=self.user.last_name,
                                                                  filename=self.uploaded_filename
                                                                  )
        # upload the file with the specified file path
        try:
            self.dbx.files_upload(read_file, '{path}'.format(path=user_filepath_name))
            return self.uploaded_filename
        except dropbox.files.UploadError as e:
            return e &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:15:09 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/266409#M15630</guid>
      <dc:creator>kaistullich</dc:creator>
      <dc:date>2019-05-29T09:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Upload PDF files/proper encoding</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/266563#M15636</link>
      <description>&lt;P&gt;[Cross-linking for reference:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/48970161/pdf-encoding-to-upload-to-dropbox-api" target="_blank"&gt;https://stackoverflow.com/questions/48970161/pdf-encoding-to-upload-to-dropbox-api&lt;/A&gt; ]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using `open`, `read`, and `files_upload` is the right way to upload files like this. The&amp;nbsp;Dropbox API will just accept whatever data you send it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just tried this and it's working properly for me. I can upload a local PDF file and the resulting uploaded file is viewable on the web site. Can you check that you're storing and retrieving the correct data at each step leading up to that `files_upload` call in your code (e.g., in your `save` method, etc.)?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 16:33:37 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/266563#M15636</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-02-26T16:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Upload PDF files/proper encoding</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/266587#M15641</link>
      <description>&lt;P&gt;Hi Greg,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&amp;nbsp; I have just realized that the issue is not with my code, but rather with the PDF file itself. The PDF file that I was trying to upload has "interactive fields" a user has to fill out in Adobe Reader. For some reason Dropbox does not like that, this is something I will have to look into.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other PDF files that do not have interactive fields work just fine with uploading and I can view them on Dropbox files.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 17:55:08 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/266587#M15641</guid>
      <dc:creator>kaistullich</dc:creator>
      <dc:date>2018-02-26T17:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Upload PDF files/proper encoding</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/334643#M19523</link>
      <description>Any update on this situation. I am having a similar problem. Unfortunately, in my senecio i can not controll the source of the PDF. Is there a way to not get a corroupted off out of the api the the same file is fine out of the web UI?</description>
      <pubDate>Tue, 19 Mar 2019 13:22:51 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/334643#M19523</guid>
      <dc:creator>Psome</dc:creator>
      <dc:date>2019-03-19T13:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Upload PDF files/proper encoding</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/334661#M19525</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1045912"&gt;@Psome&lt;/a&gt;&amp;nbsp;When downloading a file from the&amp;nbsp;Dropbox API, it will just return whatever raw data was uploaded.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since in your case the file is displaying in the&amp;nbsp;Dropbox web UI, it sounds like the issue you're seeing may be slightly different than the original issue in this thread. I'll follow up with you privately to see if we can help troubleshoot this.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 15:03:24 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-PDF-files-proper-encoding/m-p/334661#M19525</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2019-03-19T15:03:24Z</dc:date>
    </item>
  </channel>
</rss>

