Reputation: 190
Can anybody share an example of using sharing_get_shared_link_file() method in the dropbox API? I cannot seem to be able to get it working.
I keep getting the error:
'_io.TextIOWrapper' object has no attribute 'request'
Thank you.
Upvotes: 2
Views: 2323
Reputation: 16930
Here's an example of using the sharing_get_shared_link_file
method in the official Dropbox API v2 Python SDK to download a file from Dropbox shared link:
import dropbox
ACCESS_TOKEN = "<redacted>"
dbx = dropbox.Dropbox(ACCESS_TOKEN)
shared_link = "https://www.dropbox.com/s/t1emirfeqbnu8tu/hello.txt?dl=0"
metadata, res = dbx.sharing_get_shared_link_file(url=shared_link)
print(metadata)
print(res.text) # or res.content, or iter_content, or iter_lines, etc. as needed
metadata
is the SharedLinkMetadata
for the file, and res
is the requests.Response
that you can use to download the file content.
Upvotes: 2