> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# S3FileLoader 集成

> 使用 LangChain JavaScript 与 S3FileLoader 文档加载器集成。

<Tip>
  **兼容性**

  仅在 Node.js 上可用。
</Tip>

本文介绍如何从 s3 文件对象加载文档对象。

## 设置

要运行此索引，您需要已设置并准备好使用 Unstructured，且其位于一个可用的 URL 端点。它也可以配置为在本地运行。

有关如何操作的信息，请参阅 [Unstructured 文件加载器文档](/oss/javascript/integrations/document_loaders/file_loaders/unstructured)。

您还需要安装官方 AWS SDK：

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
npm install @langchain/community @langchain/core @aws-sdk/client-s3
```

## 用法

配置好 Unstructured 后，您可以使用 S3 加载器加载文件，然后将其转换为 Document。

您可以选择提供 s3Config 参数来指定您的存储桶区域、访问密钥和秘密访问密钥。如果未提供这些信息，您需要在环境中设置它们（例如，通过运行 `aws configure`）。

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { S3Loader } from "@langchain/community/document_loaders/web/s3";

const loader = new S3Loader({
  bucket: "my-document-bucket-123",
  key: "AccountingOverview.pdf",
  s3Config: {
    region: "us-east-1",
    credentials: {
      accessKeyId: "AKIAIOSFODNN7EXAMPLE",
      secretAccessKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
    },
  },
  unstructuredAPIURL: "http://localhost:8000/general/v0/general",
  unstructuredAPIKey: "", // 此字段很快将变为必填项
});

const docs = await loader.load();

console.log(docs);
```

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档连接](/use-these-docs)到 Claude、VSCode 等，通过 MCP 获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/document_loaders/web_loaders/s3.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
