<?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: Python 2.7 upload error in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292242#M17838</link>
    <description>&lt;P&gt;I may have done an update (sudo get-apt update) recently, I can't remember.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Aug 2018 19:01:34 GMT</pubDate>
    <dc:creator>mattps</dc:creator>
    <dc:date>2018-08-17T19:01:34Z</dc:date>
    <item>
      <title>Python 2.7 upload error</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292233#M17835</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was working up until a few weeks ago and I can't for the life of me see what is wrong - maybe a fresh set of eyes will help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to loop through the contents of a directory and upload the unique files to an applicaiton folder in dropbox apps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import dropbox
import os
from datetime import datetime

access_token = '########################'

def upload_file(file_from, file_to):
    print "Source :"+file_from
    print "Dest   :"+file_to
    dbx = dropbox.Dropbox(access_token)
    f = open(file_from, 'rb')
    dbx.files_upload(f.read(), file_to)



for jpgfile in os.listdir("/home/pi/pir/captures/jpg"):
    if jpgfile.endswith(".jpg"):
        print datetime.now().strftime("%y/%m/%d %H:%M:%S")+": "+"Uploading capture image."#
        file_from='/home/pi/pir/captures/jpg/180817182433.jpg'
        file_to = '/PIR_APP/180817182433.jpg&lt;BR /&gt;        upload_file(file_from, file_to)&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Note, I have hardcoded the file name for testing purposes.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "dp_test.py", line 26, in &amp;lt;module&amp;gt;&lt;BR /&gt;upload_file(file_from, file_to)&lt;BR /&gt;File "dp_test.py", line 14, in upload_file&lt;BR /&gt;dbx.files_upload(f.read(), file_to)&lt;BR /&gt;File "/usr/local/lib/python2.7/dist-packages/dropbox/base.py", line 2207, in files_upload&lt;BR /&gt;f,&lt;BR /&gt;File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 274, in request&lt;BR /&gt;timeout=timeout)&lt;BR /&gt;File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 365, in request_json_string_with_retry&lt;BR /&gt;timeout=timeout)&lt;BR /&gt;File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 449, in request_json_string&lt;BR /&gt;timeout=timeout,&lt;BR /&gt;File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 500, in post&lt;BR /&gt;return self.request('POST', url, data=data, json=json, **kwargs)&lt;BR /&gt;File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 457, in request&lt;BR /&gt;resp = self.send(prep, **send_kwargs)&lt;BR /&gt;File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send&lt;BR /&gt;r = adapter.send(request, **kwargs)&lt;BR /&gt;File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 362, in send&lt;BR /&gt;timeout=timeout&lt;BR /&gt;File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 516, in urlopen&lt;BR /&gt;body=body, headers=headers)&lt;BR /&gt;File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 308, in _make_request&lt;BR /&gt;conn.request(method, url, **httplib_request_kw)&lt;BR /&gt;File "/usr/lib/python2.7/httplib.py", line 1039, in request&lt;BR /&gt;self._send_request(method, url, body, headers)&lt;BR /&gt;File "/usr/lib/python2.7/httplib.py", line 1073, in _send_request&lt;BR /&gt;self.endheaders(body)&lt;BR /&gt;File "/usr/lib/python2.7/httplib.py", line 1035, in endheaders&lt;BR /&gt;self._send_output(message_body)&lt;BR /&gt;File "/usr/lib/python2.7/httplib.py", line 879, in _send_output&lt;BR /&gt;self.send(msg)&lt;BR /&gt;File "/usr/lib/python2.7/httplib.py", line 855, in send&lt;BR /&gt;self.sock.sendall(data)&lt;BR /&gt;File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 208, in sendall&lt;BR /&gt;return self.connection.sendall(data)&lt;BR /&gt;File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 977, in sendall&lt;BR /&gt;self._raise_ssl_error(self._ssl, result)&lt;BR /&gt;File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 849, in _raise_ssl_error&lt;BR /&gt;raise WantWriteError()&lt;BR /&gt;OpenSSL.SSL.WantWriteError&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:10:59 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292233#M17835</guid>
      <dc:creator>mattps</dc:creator>
      <dc:date>2019-05-29T09:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python 2.7 upload error</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292236#M17836</link>
      <description>&lt;P&gt;It looks like this is failing at a much lower level than the&amp;nbsp;Dropbox SDK, so I'm afraid I can't offer too much insight. For reference, here's &lt;A href="https://pyopenssl.org/en/stable/api/ssl.html#OpenSSL.SSL.WantWriteError" target="_blank"&gt;the documentation for the 'OpenSSL.SSL.WantWriteError' error&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your&amp;nbsp;Dropbox code looks fine though, and I just tried it and it worked for me (when putting in a valid path on my computer).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A few thoughts to try to narrow this down:&lt;/P&gt;
&lt;P&gt;- Is there anything on&amp;nbsp;the network connection, e.g., firewall, proxy, etc., that may be interfering with the Dropbox API HTTPS connection (to content.dropboxapi.com in particular, for uploads)?&lt;/P&gt;
&lt;P&gt;- Does this happen only for specific file(s), or any files?&lt;/P&gt;
&lt;P&gt;- Does downloading work?&lt;/P&gt;
&lt;P&gt;- Does getting metadata work (e.g., files_list_folder or files_get_metadata)?&lt;/P&gt;
&lt;P&gt;- Did you change/update any libraries when this broke?&lt;/P&gt;
&lt;P&gt;- Have you tried this on another computer, and if so does this issue reproduce elsewhere?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Aug 2018 18:49:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292236#M17836</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-08-17T18:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python 2.7 upload error</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292241#M17837</link>
      <description>&lt;P&gt;A bit more testing...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I fi I cange the file type filter to ".py" and remove the hardcoded filenames it works and the files get uploaded. So the DropBox API doesn't work with JPG files anymore????&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Aug 2018 19:00:26 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292241#M17837</guid>
      <dc:creator>mattps</dc:creator>
      <dc:date>2018-08-17T19:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python 2.7 upload error</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292242#M17838</link>
      <description>&lt;P&gt;I may have done an update (sudo get-apt update) recently, I can't remember.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Aug 2018 19:01:34 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292242#M17838</guid>
      <dc:creator>mattps</dc:creator>
      <dc:date>2018-08-17T19:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python 2.7 upload error</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292244#M17839</link>
      <description>&lt;P&gt;Thanks for the link but I'm going to try the following as a workaround:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.adafruit.com/cloud-cam-connected-raspberry-pi-security-camera/dropbox-sync" target="_blank"&gt;https://learn.adafruit.com/cloud-cam-connected-raspberry-pi-security-camera/dropbox-sync&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Aug 2018 19:10:14 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292244#M17839</guid>
      <dc:creator>mattps</dc:creator>
      <dc:date>2018-08-17T19:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Python 2.7 upload error</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292247#M17840</link>
      <description>The Dropbox API certainly still works with .jpg files. (I tested your code with a .jpg file in fact.)&lt;BR /&gt;&lt;BR /&gt;At the layer where this is failing, the file type shouldn't matter anyway. It may have to do with the file size though. Perhaps try to different sizes to verify that?&lt;BR /&gt;&lt;BR /&gt;Otherwise, it if you did do an update, it may be a bug in one of those lower level libraries.</description>
      <pubDate>Fri, 17 Aug 2018 19:12:40 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Python-2-7-upload-error/m-p/292247#M17840</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-08-17T19:12:40Z</dc:date>
    </item>
  </channel>
</rss>

