<?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 Uploaded Files are Currupt (Flask, Python) in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Uploaded-Files-are-Currupt-Flask-Python/m-p/460556#M23650</link>
    <description>&lt;P&gt;Hey, guys so I'm experimenting with the Dropbox python API using Flask. I managed to upload files but all the files I've uploaded are only 16 bytes in size and are unable to be opened. here's the code I'm using.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTML Form:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;div style="text-align: center" class="form"&amp;gt;
          &amp;lt;form class="needs-validation" novalidate action="/uploadtest" method="POST" enctype="multipart/form-data"&amp;gt;
            &amp;lt;div class="col-md-12"&amp;gt;
              &amp;lt;div class="form-group"&amp;gt;
                &amp;lt;label for="name"&amp;gt;Choose file&amp;lt;/label&amp;gt;
                &amp;lt;input type="file" accept=".xlsx, .jpg" name="file" id="fileToUpload" class="form-control" placeholder="John Smith"
                  required&amp;gt;
                &amp;lt;div class="valid-feedback"&amp;gt;
                  Looks good!
                &amp;lt;/div&amp;gt;
                &amp;lt;div class="invalid-feedback"&amp;gt;
                  Please choose a .xlsx file.
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;button type="submit" class="btn btn-success" value=""&amp;gt;Submit&amp;lt;/button&amp;gt;
          &amp;lt;/form&amp;gt;
        &amp;lt;/div&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Python Flask Route&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;@app.route('/uploadtest', methods=['POST', 'GET'])
def get_dropbox_files():
    if request.method == 'POST':
        uploadedfile = request.files['file']
        client = dbx_client
        f = secure_filename(uploadedfile.filename)
        path="/nameinlights/" + f
        dbx_client.files_upload(f.encode(), path)
        flash("Added" + " " + f + " " + "to Name in Lights Folder", 'success')

            
    return render_template('uploadtest.html', file_list=file_list)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Oct 2020 05:06:08 GMT</pubDate>
    <dc:creator>jmccolgan93</dc:creator>
    <dc:date>2020-10-12T05:06:08Z</dc:date>
    <item>
      <title>Uploaded Files are Currupt (Flask, Python)</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Uploaded-Files-are-Currupt-Flask-Python/m-p/460556#M23650</link>
      <description>&lt;P&gt;Hey, guys so I'm experimenting with the Dropbox python API using Flask. I managed to upload files but all the files I've uploaded are only 16 bytes in size and are unable to be opened. here's the code I'm using.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTML Form:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;div style="text-align: center" class="form"&amp;gt;
          &amp;lt;form class="needs-validation" novalidate action="/uploadtest" method="POST" enctype="multipart/form-data"&amp;gt;
            &amp;lt;div class="col-md-12"&amp;gt;
              &amp;lt;div class="form-group"&amp;gt;
                &amp;lt;label for="name"&amp;gt;Choose file&amp;lt;/label&amp;gt;
                &amp;lt;input type="file" accept=".xlsx, .jpg" name="file" id="fileToUpload" class="form-control" placeholder="John Smith"
                  required&amp;gt;
                &amp;lt;div class="valid-feedback"&amp;gt;
                  Looks good!
                &amp;lt;/div&amp;gt;
                &amp;lt;div class="invalid-feedback"&amp;gt;
                  Please choose a .xlsx file.
                &amp;lt;/div&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;button type="submit" class="btn btn-success" value=""&amp;gt;Submit&amp;lt;/button&amp;gt;
          &amp;lt;/form&amp;gt;
        &amp;lt;/div&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Python Flask Route&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;@app.route('/uploadtest', methods=['POST', 'GET'])
def get_dropbox_files():
    if request.method == 'POST':
        uploadedfile = request.files['file']
        client = dbx_client
        f = secure_filename(uploadedfile.filename)
        path="/nameinlights/" + f
        dbx_client.files_upload(f.encode(), path)
        flash("Added" + " " + f + " " + "to Name in Lights Folder", 'success')

            
    return render_template('uploadtest.html', file_list=file_list)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 05:06:08 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Uploaded-Files-are-Currupt-Flask-Python/m-p/460556#M23650</guid>
      <dc:creator>jmccolgan93</dc:creator>
      <dc:date>2020-10-12T05:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Uploaded Files are Currupt (Flask, Python)</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Uploaded-Files-are-Currupt-Flask-Python/m-p/460803#M23654</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you call &lt;CODE&gt;file_upload&lt;/CODE&gt;, you're actually uploading the file's name as a string. Each file is coming out to 16 bytes because the strings are being generated by &lt;CODE&gt;secure_filename&lt;/CODE&gt; and are probably a standard length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can fix it by changing the first variable you're passing to &lt;CODE&gt;file_upload&lt;/CODE&gt;.&lt;/P&gt;
&lt;PRE&gt;        dbx_client.files_upload(f.encode(), path)&lt;/PRE&gt;
&lt;P&gt;should be&lt;/P&gt;
&lt;PRE&gt;        dbx_client.files_upload(&lt;STRONG&gt;uploadedfile&lt;/STRONG&gt;.encode(), path)
&lt;/PRE&gt;
&lt;P&gt;It looks like you're just working with the filename&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 19:17:42 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Uploaded-Files-are-Currupt-Flask-Python/m-p/460803#M23654</guid>
      <dc:creator>TaylorKrusen</dc:creator>
      <dc:date>2020-10-12T19:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Uploaded Files are Currupt (Flask, Python)</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Uploaded-Files-are-Currupt-Flask-Python/m-p/460857#M23657</link>
      <description>&lt;P&gt;thanks man! i had to change "encode()" for "read()" thanks for the help man!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;dbx_client.files_upload(uploadedfile.read(), path)&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Oct 2020 23:22:08 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Uploaded-Files-are-Currupt-Flask-Python/m-p/460857#M23657</guid>
      <dc:creator>jmccolgan93</dc:creator>
      <dc:date>2020-10-12T23:22:08Z</dc:date>
    </item>
  </channel>
</rss>

