在Python中获取文件夹中的文件URL
我的Dropbox中有很多文件夹,其中包含图片,我正在尝试在特定文件夹中获取所有图片的列表。
import requests
import json
import dropbox
TOKEN = 'my_access_token'
dbx = dropbox.Dropbox(TOKEN)
for entry in dbx.files_list_folder('/Main/Test').entries:
# print(entry.name)
print(entry.file_requests.FileRequest.url)
# print(entry.files.Metadata.path_lower)
# print(entry.file_properties.PropertyField)
正确打印条目名称在文件夹中列出了所有文件名,但是其他所有内容'filemetadata'对象没有属性'get_url'
。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
方法返回
listFolderResult
,其中listfolderresult.entries
是 。另外,请注意,您不能保证您可以从
files_list_folder
方法,因此请确保实现files_list_folder_continue
。请参阅有关更多信息。您提到的链接是共享链接。 自己不包含这样的链接。您可以从 path_lower 。例如,在代码中的循环的
中,看起来像
print(entry.path_lower)
。您应该使用 列出现有链接和/或
sharing_create_create_shared_shared_link_with_with_settings
根据需要创建任何特定文件的共享链接。The
files_list_folder
method returns aListFolderResult
, whereListFolderResult.entries
is a list ofMetadata
. Files in particular areFileMetadata
.Also, note that you aren't guaranteed to get everything back from
files_list_folder
method, so make sure you implementfiles_list_folder_continue
as well. Refer to the documentation for more information.The kind of link you mentioned is a shared link.
FileMetadata
don't themselves contain a link like that. You can get the path frompath_lower
though. For example, in thefor
loop in your code, that would look likeprint(entry.path_lower)
.You should use
sharing_list_shared_links
to list existing links, and/orsharing_create_shared_link_with_settings
to create shared links for any particular file as needed.