Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

Yann_PGS's avatar
Yann_PGS
Explorer | Level 4
9 years ago
Solved

Error to send larger file under python

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

 

7 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    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"`.
  • Yann_PGS's avatar
    Yann_PGS
    Explorer | Level 4
    9 years ago

    Greg,

    have you a python script to easly sync a folder ?

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

  • Yann_PGS's avatar
    Yann_PGS
    Explorer | Level 4
    9 years ago

    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.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    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?

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!