跳至主要内容

Dropbox

Dropbox 是一项文件托管服务,它将所有内容(传统文件、云内容和 Web 快捷方式)整合在一个地方。

此笔记本介绍如何从 Dropbox 加载文档。除了文本和 PDF 文件等常见文件外,它还支持 Dropbox Paper 文件。

先决条件

  1. 创建一个 Dropbox 应用。
  2. 授予该应用以下范围权限:files.metadata.readfiles.content.read
  3. 生成访问令牌:https://www.dropbox.com/developers/apps/create
  4. pip install dropbox(需要 pip install "unstructured[pdf]" 用于 PDF 文件类型)。

说明

`DropboxLoader` 需要您创建一个 Dropbox 应用并生成一个访问令牌。这可以通过 https://www.dropbox.com/developers/apps/create 完成。您还需要安装 Dropbox Python SDK(pip install dropbox)。

DropboxLoader 可以从 Dropbox 文件路径列表或单个 Dropbox 文件夹路径加载数据。这两个路径都应相对于与访问令牌关联的 Dropbox 帐户的根目录。

pip install dropbox
Requirement already satisfied: dropbox in /Users/rbarragan/.local/share/virtualenvs/langchain-kv0dsrF5/lib/python3.11/site-packages (11.36.2)
Requirement already satisfied: requests>=2.16.2 in /Users/rbarragan/.local/share/virtualenvs/langchain-kv0dsrF5/lib/python3.11/site-packages (from dropbox) (2.31.0)
Requirement already satisfied: six>=1.12.0 in /Users/rbarragan/.local/share/virtualenvs/langchain-kv0dsrF5/lib/python3.11/site-packages (from dropbox) (1.16.0)
Requirement already satisfied: stone>=2 in /Users/rbarragan/.local/share/virtualenvs/langchain-kv0dsrF5/lib/python3.11/site-packages (from dropbox) (3.3.1)
Requirement already satisfied: charset-normalizer<4,>=2 in /Users/rbarragan/.local/share/virtualenvs/langchain-kv0dsrF5/lib/python3.11/site-packages (from requests>=2.16.2->dropbox) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in /Users/rbarragan/.local/share/virtualenvs/langchain-kv0dsrF5/lib/python3.11/site-packages (from requests>=2.16.2->dropbox) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/rbarragan/.local/share/virtualenvs/langchain-kv0dsrF5/lib/python3.11/site-packages (from requests>=2.16.2->dropbox) (2.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /Users/rbarragan/.local/share/virtualenvs/langchain-kv0dsrF5/lib/python3.11/site-packages (from requests>=2.16.2->dropbox) (2023.7.22)
Requirement already satisfied: ply>=3.4 in /Users/rbarragan/.local/share/virtualenvs/langchain-kv0dsrF5/lib/python3.11/site-packages (from stone>=2->dropbox) (3.11)
Note: you may need to restart the kernel to use updated packages.
from langchain_community.document_loaders import DropboxLoader
API 参考:DropboxLoader
# Generate access token: https://www.dropbox.com/developers/apps/create.
dropbox_access_token = "<DROPBOX_ACCESS_TOKEN>"
# Dropbox root folder
dropbox_folder_path = ""
loader = DropboxLoader(
dropbox_access_token=dropbox_access_token,
dropbox_folder_path=dropbox_folder_path,
recursive=False,
)
documents = loader.load()
File /JHSfLKn0.jpeg could not be decoded as text. Skipping.
File /A REPORT ON WILES’ CAMBRIDGE LECTURES.pdf could not be decoded as text. Skipping.
for document in documents:
print(document)

此页面是否有帮助?


您也可以留下详细的反馈 在 GitHub 上.