[英]Can I use the Dropbox API to Download Files from a regular link?
I would like to download files from a link a received to Dropbox. 我想从收到的链接下载文件到Dropbox。 I created an API token, but I'm not sure the type of link I received is sufficient. 我创建了一个API令牌,但我不确定我收到的链接类型是否足够。
Using these docs , I tried retrieving the file but am receiving the following error: 使用这些文档 ,我尝试检索文件,但收到以下错误:
ApiError: ApiError('', GetSharedLinkFileError('shared_link_access_denied', None))
Here's my code: 这是我的代码:
import dropbox
dbx = dropbox.Dropbox("{ACCESS TOKEN}")
dbx.users_get_current_account()
download_path = '{LOCAL PATH}'
url = 'https://www.dropbox.com/sh/{DROPBOX FOLDER}?dl=0'
dbx.sharing_get_shared_link_file_to_file(download_path, url, path=None, link_password=None)
I tried replacing the sh
with s
based on this , no success. 我试图取代sh
用s
基于此 ,没有成功。
Do I have the link I need? 我有我需要的链接吗? Is it something in the code? 这是代码中的东西吗? Thanks in advance! 提前致谢!
Dropbox shared links with "/sh"
refer to folders. 带有"/sh"
Dropbox共享链接指的是文件夹。 These links are valid for use with sharing_get_shared_link_file_to_file
, but since they refer to folders and not individual files, you do need to specify the path
parameter to indicate which file in the linked folder you want. 这些链接适用于sharing_get_shared_link_file_to_file
,但由于它们引用文件夹而不是单个文件,因此您需要指定path
参数以指示所需链接文件夹中的哪个文件。
Here's a working example: 这是一个有效的例子:
import dropbox
dbx = dropbox.Dropbox("{ACCESS TOKEN}")
file_path = '/dahlia_l.jpg'
download_path = 'download.jpg'
url = 'https://www.dropbox.com/sh/ljrkl8kbddx8n1c/AAACNrUwqPSVv27oh97QhN0Za?dl=0'
res = dbx.sharing_get_shared_link_file_to_file(download_path, url, path=file_path)
print(res)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.