Dropbox Core API列出所有文件夹 [英] Dropbox Core API list all folders

查看:90
本文介绍了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)

这篇关于Dropbox Core API列出所有文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆