cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error to send larger file under python

Error to send larger file under python

Yann_PGS
Explorer | Level 4

Hi Dropbox Team,

i'm using a script to send larger files (more 1 GB) but i have an error :

 

Script i use :

import dropbox, sys, os
dbx = dropbox.Dropbox('MY KEY')
file_path = 'My local file_path'
f = open(file_path, "rb")
file_size = os.path.getsize(file_path)
dest_path = 'My Dropbox dest_path'
CHUNK_SIZE = 4 * 1024 * 1024

if file_size <= CHUNK_SIZE:

    print(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() < file_size:
        if ((file_size - f.tell()) <= 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()

The error :

Traceback (most recent call last):
  File "upload-bakcup-dropbox.py", line 31, in <module>
    print(dbx.files_upload(f.read(), dest_path))
  File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\dropbox-0.0.0-py3.6.egg\dropbox\base.py", line 2076, in files_upload
    f,
  File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\dropbox-0.0.0-py3.6.egg\dropbox\dropbox.py", line 256, in request
    user_message_locale)
dropbox.exceptions.ApiError: ApiError('ecbd1ad61a0596454c7943e4243d10a7', UploadError('path', UploadWriteFailed(reason=WriteError('conflict', WriteConflictError('folder', None)), u
pload_session_id='AAAAAAAAAeBQJPdCxI5KAQ')))

Could you help me ?

Thanks

 

1 Accepted Solution

Accepted Solutions

Re: Error to send larger file under python

Greg-DB
Dropboxer
This path/conflict/folder error indicates that the upload failed because there is already a folder at the path where you're trying to upload the file (specified by `dest_path` in your code):

https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.files.WriteConflictError

If you're trying to upload the file into that folder, you'll need to include the full desired path, including the file name. E.g., `"/folder/file.ext"`, instead of just `"/folder"`.

View solution in original post

7 Replies 7

Re: Error to send larger file under python

Greg-DB
Dropboxer
This path/conflict/folder error indicates that the upload failed because there is already a folder at the path where you're trying to upload the file (specified by `dest_path` in your code):

https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.files.WriteConflictError

If you're trying to upload the file into that folder, you'll need to include the full desired path, including the file name. E.g., `"/folder/file.ext"`, instead of just `"/folder"`.

View solution in original post

Re: Error to send larger file under python

Yann_PGS
Explorer | Level 4

Thanks Greg, 

it was only this 🙂

Re: Error to send larger file under python

Yann_PGS
Explorer | Level 4

Greg,

have you a python script to easly sync a folder ?

This folder has subdirectories (1 level) and each subdirectories has multiple lager files.

Re: Error to send larger file under python

Greg-DB
Dropboxer
I don't know if it offers the exact logic you need, but this example app may be helpful:

https://github.com/dropbox/dropbox-sdk-python/blob/master/example/updown.py

Re: Error to send larger file under python

Yann_PGS
Explorer | Level 4

Hi Greg, 

sorry i have an error with this script updown.py.

 

Traceback (most recent call last):
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 356, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 1065, in _send_output
self.send(chunk)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 986, in send
self.sock.sendall(data)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 965, in sendall
v = self.send(data[count:])
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 935, in send
return self._sslobj.write(data)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 636, in write
return self._sslobj.write(data)
socket.timeout: The write operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\util\retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 356, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 1065, in _send_output
self.send(chunk)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\http\client.py", line 986, in send
self.sock.sendall(data)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 965, in sendall
v = self.send(data[count:])
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 935, in send
return self._sslobj.write(data)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 636, in write
return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', timeout('The write operation timed out',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "updown.py", line 246, in <module>
main()
File "updown.py", line 107, in main
upload(dbx, fullname, folder, subfolder, name)
File "updown.py", line 184, in upload
mute=True)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\dropbox-8.5.0-py3.6.egg\dropbox\base.py", line 2073, in files_upload
f,
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\dropbox-8.5.0-py3.6.egg\dropbox\dropbox.py", line 234, in request
timeout=timeout)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\dropbox-8.5.0-py3.6.egg\dropbox\dropbox.py", line 325, in request_json_string_with_retry
timeout=timeout)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\dropbox-8.5.0-py3.6.egg\dropbox\dropbox.py", line 409, in request_json_string
timeout=timeout,
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 549, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 502, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 612, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Administrateur\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', timeout('The write operation timed out',))

I think it's the script i need.

Re: Error to send larger file under python

Greg-DB
Dropboxer
How big is the file you're trying to upload when this occurs? The updown sample doesn't use upload sessions, so it can only handle small files. For example, the 1 GB file you mentioned earlier would be too big. If you need it to support large files, you'll need to update it to use upload sessions.

Otherwise, this might just indicate transient server/network issues. The Dropbox content servers are working properly in my testing right now though. If you're still seeing this, there may be something interfering with your connection. Do you have anything on your network connection, e.g., firewall or proxy, that may be preventing your app from successfully connecting to the Dropbox servers?

Re: Error to send larger file under python

karthik_siddhu
New member | Level 2
Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    karthik_siddhu New member | Level 2
  • User avatar
    Greg-DB Dropboxer
  • User avatar
    Yann_PGS Explorer | Level 4
What do Dropbox user levels mean?
Need more support?