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
richard338
3 years agoNew member | Level 2
[Errno 13] Permission Denied; Download Convert to String from Bytes; Upload Bytes Not String
#Solved!
#Python SDK (python package) for Dropbox
#Problem
dbx.files_download_to_file(download_path="/downloads", path="/fileToDownload.txt")
#returns [Errno 13] Permission Denied
#Solution
#Omit "/" before directory path name
#download_path="downloads"
dbx.files_download_to_file(download_path="downloads", path="/fileToDownload.txt")
#end Solution section
#Download - Convert String to Bytes (search label references: convert text to bytes; str() to b''; string to b''; str() to b""; string to b"")
#Also; download returns bytes variable to save to file; however, you can decode it, to save the text as a string (python str() variable type), as follows:
metadata, variable_result = dbx.files_download(path='/fileToDownload.txt')
#bytes are returned as variable_result.content
#change them to a string, as follows:
variable_bytes = variable_result.content
variable_string = variable_bytes.decode("utf-8")
f = open("saveTextHere.txt", "x")
f.write(variable_string)
f.close()
#Upload - Convert Bytes to String (search label references: convert text to bytes; str() to bytes; str() to b''; str() to b""; string to b''; string to b"")
t = str("My text to save to upload file. Upload this text to user's Dropbox.com.")
b = t.encode('ascii')
f = '/newFileAtDropbox.txt'
dbx.files_upload(b, f)
#view your uploaded file; file location - Dropbox.com, folder: Dropbox/Apps/[appFolderName]
- Solved, above.
- richard338New member | Level 2Solved, above.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,882 PostsLatest Activity: 2 hours 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!