cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Discuss Dropbox Developer & API

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

Python 3.5 API upload error

Explorer | Level 4

I'm using a Raspberry Pi 3 B+ with the a Pi Camera to record surveillance images and occasionally upload them to my Dropbox account. The Python script runs until it's time to upload the images to Dropbox and then this error occurs:

[UPLOAD] Wednesday 12 December 2018 07:43:50AM
Traceback (most recent call last):
File "pi_surveillance.py", line 126, in <module>
client.files_upload(open(t.path, "rb").read(), path)
File "/home/pi/.virtualenvs/cv/lib/python3.5/site-packages/dropbox/base.py", line 2187, in files_upload
f,
File "/home/pi/.virtualenvs/cv/lib/python3.5/site-packages/dropbox/dropbox.py", line 296, in request
user_message_locale)
dropbox.exceptions.ApiError: ApiError('88dea4768f5b9c6b5cfc7e05ce25133d', UploadError('path', UploadWriteFailed

I was previously receiving a "malformed token" error, but it has since been replaced with this new error. Can anyone steer me in the right direction. Any help is greatly appreciated.

 

Regards,

delta1071

 

 

1 Accepted Solution

Accepted Solutions
Highlighted

Re: Python 3.5 API upload error

Dropboxer
Dropboxer

Thanks! I see you're referencing a Dropbox web site URL in your path. When identifying files by path on the Dropbox API, you should not use Dropbox web site URLs like this.

You only need to write them relative to "root", so e.g., you might use a value like "/Pi Image Search/123.jpg", to upload a file into a folder named "Pi Image Search", or just "/123.jpg" to upload a file into whatever root your app has.

View solution in original post

12 Replies 12
Highlighted

Re: Python 3.5 API upload error

Dropboxer
Dropboxer

It looks like the output you shared here is cut off. There should be more after "UploadWriteFailed". Can you share the rest of that so we can take a look? Thanks in advance! 

Highlighted

Re: Python 3.5 API upload error

Explorer | Level 4

Sorry Greg, didn't notice that. Here's the entire error message:

[UPLOAD] Thursday 13 December 2018 03:13:03PM
Traceback (most recent call last):
File "pi_surveillance.py", line 126, in <module>
client.files_upload(open(t.path, "rb").read(), path)
File "/home/pi/.virtualenvs/cv/lib/python3.5/site-packages/dropbox/base.py", line 2187, in files_upload
f,
File "/home/pi/.virtualenvs/cv/lib/python3.5/site-packages/dropbox/dropbox.py", line 296, in request
user_message_locale)
dropbox.exceptions.ApiError: ApiError('b61692b65ac6c9567e93b708e5b09354', UploadError('path', UploadWriteFailed(reason=WriteError('malformed_path', None), upload_session_id='AAAAAAAAAFpRjEudLSydjw')))

Thanks,  

delta1071

Highlighted

Re: Python 3.5 API upload error

Dropboxer
Dropboxer

Thanks! I see you're getting a 'malformed_path' error. That should indicate that the path you're giving for the upload isn't in a valid format. What value are you supplying as the 'path' parameter (i.e., the second parameter on files_upload)?

Highlighted

Re: Python 3.5 API upload error

Explorer | Level 4

Not sure where to find the files_upload string. The Dropbox upload section of the script is this:

# upload the image to Dropbox and clean up the temporary image
print("[UPLOAD] {}".format(ts))
path = "/{base_path}/{timestamp}.jpg".format(
base_path=conf["dropbox_base_path"], timestamp=ts)
client.files_upload(open(t.path, "rb").read(), path)
t.cleanup()

Highlighted

Re: Python 3.5 API upload error

Dropboxer
Dropboxer

Thanks, I am referring to that 'path' variable you're passing in to files_upload. 

Can you share the actual value in 'path' after that 'format' call? I.e., "print(path)" just before you call files_upload.

Highlighted

Re: Python 3.5 API upload error

Explorer | Level 4

Greg, 

My conf.json file contains this Dropbox entry:

"use_dropbox": true,
"dropbox_access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"dropbox_base_path": "https://www.dropbox.com/home/Pi%20Image%20Search",

 

 

Highlighted

Re: Python 3.5 API upload error

Dropboxer
Dropboxer

Thanks! I see you're referencing a Dropbox web site URL in your path. When identifying files by path on the Dropbox API, you should not use Dropbox web site URLs like this.

You only need to write them relative to "root", so e.g., you might use a value like "/Pi Image Search/123.jpg", to upload a file into a folder named "Pi Image Search", or just "/123.jpg" to upload a file into whatever root your app has.

View solution in original post

Highlighted

Re: Python 3.5 API upload error

Explorer | Level 4

The files are uploading now. It seems like it takes a while before the files appear in my Dropbox folder, because even after changing the upload path, the images were showing up in the local folder folder that I was running the script from, but not in the Dropbox folder. But when I checked the Dropbox folder today, the images from Friday morning were there. So, I assume it's working now. Thanks for your help.

 

Regards,

delta1071

Highlighted

Re: Python 3.5 API upload error

Dropboxer
Dropboxer

I'm glad to hear you have this working now.

For reference though, note that the files uploaded via the Dropbox API should be available on the Dropbox API/web site as soon as the upload API call returns.

If you weren't seeing the file immediately on the Dropbox web site or a mobile client, it's possible you just needed to refresh, or if you were looking on a desktop client, you may have some general desktop syncing issues.

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?