<?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 upload file OverflowError in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-file-OverflowError/m-p/437659#M23087</link>
    <description>&lt;P&gt;From the stack trace, I see that this code is attempting to use the 'files_upload' method to upload this file, which doesn't support files of this size. You should instead be using the upload sessions functionality for large files like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at your code, it looks like that 'files_upload' code path is mistakenly being used because you've changed the 'file_size' check to be checking the size of 'rootdir', instead of the size of the actual file to upload. You'll need to fix the code to use the size of the file to determine which upload functionality to use. That way, it will use the upload sessions code path for large files.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jul 2020 15:40:05 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2020-07-15T15:40:05Z</dc:date>
    <item>
      <title>python upload file OverflowError</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-file-OverflowError/m-p/437475#M23084</link>
      <description>&lt;P&gt;I need to upload all the files in a directory through the API, the largest file is about 20 gb, but I keep getting an OverflowError with files larger than 2GB. I'm using the example of this thread (&lt;A href="https://www.dropboxforum.com/t5/API-Support-Feedback/python-upload-big-file-example/m-p/166626" target="_blank" rel="noopener"&gt;https://www.dropboxforum.com/t5/API-Support-Feedback/python-upload-big-file-example/m-p/166626&lt;/A&gt;). But I can't make it work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the code:&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;PRE&gt;def subebackups():
    dbx = dropbox.Dropbox('MY_APP_TOKEN',timeout=36000)
    rootdir = 'ROOT_DIR'
    file_size = os.path.getsize(rootdir)
    CHUNK_SIZE = 50 * 1024 * 1024
    for dir, dirs, files in os.walk(rootdir):
        for file in files:
            file_path = os.path.join(dir, file)
            dest_path =  os.path.join('/Backups/Backups', file).replace("\\","/")
 
            with open(file_path, "rb") as f:
                if file_size &amp;lt;= CHUNK_SIZE:
                    dbx.files_upload(f.read(), dest_path)

                else:
                
                   upload_session_start_result = dbx.files_upload_session_start(f.read(CHUNK_SIZE))
                   cursor = dropbox.files.UploadSessionCursor(session_id=upload_session_start_result.session_id,
                                                              offset=f.tell())
                   commit = dropbox.files.CommitInfo(path=dest_path)

                   while f.tell() &amp;lt; file_size:
                       if ((file_size - f.tell()) &amp;lt;= CHUNK_SIZE):
                           print(dbx.files_upload_session_finish(f.read(CHUNK_SIZE),
                                                           cursor,
                                                           commit))
                       else:
                           dbx.files_upload_session_append(f.read(CHUNK_SIZE),
                                                           cursor.session_id,
                                                           cursor.offset)
                           cursor.offset = f.tell()

&lt;/PRE&gt;
&lt;P&gt;This is the ouput with files larger than 2 GB:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\Users\Ordico\Downloads\tools-master\tools-master\dropbox\SubeBackupsDropbox.py", line 66, in &amp;lt;module&amp;gt;&lt;BR /&gt;subebackups()&lt;BR /&gt;File "C:\Users\Ordico\Downloads\tools-master\tools-master\dropbox\SubeBackupsDropbox.py", line 40, in subebackups&lt;BR /&gt;dbx.files_upload(f.read(), dest_path)&lt;BR /&gt;File "C:\env\dropbox\lib\site-packages\dropbox\base.py", line 2960, in files_upload&lt;BR /&gt;r = self.request(&lt;BR /&gt;File "C:\env\dropbox\lib\site-packages\dropbox\dropbox.py", line 311, in request&lt;BR /&gt;res = self.request_json_string_with_retry(host,&lt;BR /&gt;File "C:\env\dropbox\lib\site-packages\dropbox\dropbox.py", line 461, in request_json_string_with_retry&lt;BR /&gt;return self.request_json_string(host,&lt;BR /&gt;File "C:\env\dropbox\lib\site-packages\dropbox\dropbox.py", line 557, in request_json_string&lt;BR /&gt;r = self._session.post(url,&lt;BR /&gt;File "C:\env\dropbox\lib\site-packages\requests\sessions.py", line 578, in post&lt;BR /&gt;return self.request('POST', url, data=data, json=json, **kwargs)&lt;BR /&gt;File "C:\env\dropbox\lib\site-packages\requests\sessions.py", line 530, in request&lt;BR /&gt;resp = self.send(prep, **send_kwargs)&lt;BR /&gt;File "C:\env\dropbox\lib\site-packages\requests\sessions.py", line 643, in send&lt;BR /&gt;r = adapter.send(request, **kwargs)&lt;BR /&gt;File "C:\env\dropbox\lib\site-packages\requests\adapters.py", line 439, in send&lt;BR /&gt;resp = conn.urlopen(&lt;BR /&gt;File "C:\env\dropbox\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen&lt;BR /&gt;httplib_response = self._make_request(&lt;BR /&gt;File "C:\env\dropbox\lib\site-packages\urllib3\connectionpool.py", line 392, in _make_request&lt;BR /&gt;conn.request(method, url, **httplib_request_kw)&lt;BR /&gt;File "c:\users\ordico\appdata\local\programs\python\python38\lib\http\client.py", line 1230, in request&lt;BR /&gt;self._send_request(method, url, body, headers, encode_chunked)&lt;BR /&gt;File "c:\users\ordico\appdata\local\programs\python\python38\lib\http\client.py", line 1276, in _send_request&lt;BR /&gt;self.endheaders(body, encode_chunked=encode_chunked)&lt;BR /&gt;File "c:\users\ordico\appdata\local\programs\python\python38\lib\http\client.py", line 1225, in endheaders&lt;BR /&gt;self._send_output(message_body, encode_chunked=encode_chunked)&lt;BR /&gt;File "c:\users\ordico\appdata\local\programs\python\python38\lib\http\client.py", line 1043, in _send_output&lt;BR /&gt;self.send(chunk)&lt;BR /&gt;File "c:\users\ordico\appdata\local\programs\python\python38\lib\http\client.py", line 965, in send&lt;BR /&gt;self.sock.sendall(data)&lt;BR /&gt;File "c:\users\ordico\appdata\local\programs\python\python38\lib\ssl.py", line 1204, in sendall&lt;BR /&gt;v = self.send(byte_view[count:])&lt;BR /&gt;File "c:\users\ordico\appdata\local\programs\python\python38\lib\ssl.py", line 1173, in send&lt;BR /&gt;return self._sslobj.write(data)&lt;BR /&gt;OverflowError: string longer than 2147483647 bytes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 09:26:50 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-file-OverflowError/m-p/437475#M23084</guid>
      <dc:creator>hramosvz</dc:creator>
      <dc:date>2020-07-15T09:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: python upload file OverflowError</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-file-OverflowError/m-p/437659#M23087</link>
      <description>&lt;P&gt;From the stack trace, I see that this code is attempting to use the 'files_upload' method to upload this file, which doesn't support files of this size. You should instead be using the upload sessions functionality for large files like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at your code, it looks like that 'files_upload' code path is mistakenly being used because you've changed the 'file_size' check to be checking the size of 'rootdir', instead of the size of the actual file to upload. You'll need to fix the code to use the size of the file to determine which upload functionality to use. That way, it will use the upload sessions code path for large files.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 15:40:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-file-OverflowError/m-p/437659#M23087</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-07-15T15:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: python upload file OverflowError</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-file-OverflowError/m-p/437768#M23090</link>
      <description>&lt;P&gt;You are right! it's working now. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 22:40:28 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-file-OverflowError/m-p/437768#M23090</guid>
      <dc:creator>hramosvz</dc:creator>
      <dc:date>2020-07-15T22:40:28Z</dc:date>
    </item>
  </channel>
</rss>

