You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

kentdwheeler's avatar
kentdwheeler
Explorer | Level 4
5 years ago

Re: Upload PDF files/proper encoding

I am having the same problem. I am also trying to upload a pdf that has editable fields, but I also tested it with a blank pdf and found it also would not work. below is a copy of my code. (very similar to the original post)

 

    files = os.listdir(os.getcwd())
    for f in files:
        if f.endswith('.pdf'):
            #try:
            with open(f, 'rb') as pdf:
                dbx.files_upload(pdf.read(),folder, mode=dropbox.files.WriteMode.overwrite, mute=True)
                print("Uploaded " + f)
            #except:
              #print("Failed to upload " + f)

with the error trapping commented out as shown I get the following error.

ApiError: ApiError('52f678d99929196d2932392461245c1e', UploadError('path', UploadWriteFailed(reason=WriteError('conflict', WriteConflictError('folder', None)), upload_session_id='AAAAAAABUBUiDKOvC0Pm5A')))

 

There is no conflict, I have used the overwrite mode and also made sure that there is no file already on dropbox that has that name

 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    A 'path/conflict/folder' error like this indicates that the upload failed because there is already a folder at the specified path (not a file). The "overwrite" mode will only overwrite files, not folders.

     

    When uploading a file, e.g., using files_upload, you need to specify the whole path where you want to put the uploaded file, including both any parent folders as well as the filename and extension. 

     

     

    So, for example, the value you pass to the "path" parameter should look like "/folder/file.ext", not just "/folder".

     

    In your code, you're passing in a variable named "folder" as that "path" parameter. The value of that variable isn't shown, but based on the name it sounds like it's just the folder path, not the entire desired file path. If that's so, you'll need to update your code to construct the entire file path and specify that when uploading.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,915 PostsLatest Activity: 6 hours ago
333 Following

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 or Facebook.

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!