We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
peytonshc
8 years agoExplorer | Level 3
Unable to download file to a desired path via files_download_to_file using the python api
I am using the files_download_to_file function to try and download a file from my dropbox to a specific location. As parameters I am giving it '/home/user/Desktop' and it is saying IOError: [Errno 2...
peytonshc
Explorer | Level 3
I tried that before but got TypeError: 'FileMetadata' object is not iterable when I try and write it.
Greg-DB
8 years agoDropbox Staff
It looks like there's a mistake in the documentation (we'll get that fixed up), but the files_download_to_file method actually just returns a FileMetadata object (not a tuple), so make sure you're not trying to unpack the result.
I.e., your code should look something like `metadata = dbx.files_download_to_file(...)` not `metadata, result = dbx.files_download_to_file(...)`.
I.e., your code should look something like `metadata = dbx.files_download_to_file(...)` not `metadata, result = dbx.files_download_to_file(...)`.
- peytonshc8 years agoExplorer | Level 3
That works now but I am curious why when I run the program it download the files to the directed directory as well as the current directory. I would like this to just happen in the directed directory.
- Greg-DB8 years agoDropbox StaffThe files_download_to_file method should just download a single copy of the file to wherever you specify in the download_path parameter. Can you share code that reproduces the unexpected behavior you're seeing?
- peytonshc8 years agoExplorer | Level 3
Here is an example:
with open('Resume BigRed.pdf', "wb") as f: try: metadata = dbx.files_download_to_file('/home/ubuntu-mate/Desktop/test/Resume BigRed.pdf', "/Resume BigRed.pdf")
f.write(metadata) except TypeError:
print("Ignoring TypeError")I'm using the try to avoid the TypeError for entering metadata but it runs.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months agoIf 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!