Dropbox Core API列出所有文件夹
所以我一直在玩Dropbox API。我的应用正在通过Core API从用户的保管箱中检索所有图像文件。
So I have been playing with Dropbox APIs for awhile. My app is retrieving all the image files from a user's dropbox via Core API.
现在,我想通过允许用户选择要同步的文件夹来对其进行一些改进。即,一旦他们授权了该应用程序,它将为他们提供帐户中的所有文件夹。然后,用户可以选择一个或多个文件夹,该应用程序只会从选定的文件夹中检索图像文件。
Now I want to improve it a bit by allowing users to choose which folder to sync.. i.e. once they authorise the app, it will give them all the folders inside their account. Users can then choose one or many folder(s), the app will only retrieve image files from selected folders.
是否有特定的API列出了一个文件夹中的所有文件夹用户的保管箱?
Is there a specific API that list out all folders inside a user's dropbox?
我没有使用任何SDK。
I'm not using any SDK.
使用 https://api.dropbox.com/1/metadata/dropbox/<path>
为您提供目录内容的详细信息
Using the https://api.dropbox.com/1/metadata/dropbox/<path>
gives you the details of the contents of directory
import requests
...
headers = ... # set up auth
...
params = { 'list' : 'true' }
response = requests.get('https://api.dropbox.com/1/metadata/dropbox/<directory>', params=params, headers=headers)
subdirs = [d['path'] for d in response.json()['contents'] if d['is_dir'] == True]
print(subdirs)