cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Re: Upload PDF files/proper encoding

Re: Upload PDF files/proper encoding

kentdwheeler
Explorer | Level 4

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

 

1 Reply 1

Greg-DB
Dropbox 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.

Need more support?