> ## 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.

# Google Cloud Storage 集成

> 使用 LangChain JavaScript 与 Google Cloud Storage 文档加载器集成。

<Tip>
  **兼容性**

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

本文介绍如何将 Google Cloud Storage 文件加载到 LangChain 文档中。

## 设置

要使用此加载器，您需要已经设置好 Unstructured 并使其在可用的 URL 端点上准备就绪。它也可以配置为在本地运行。

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

您还需要安装官方的 Google Cloud Storage SDK：

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
npm install @langchain/community @langchain/core @google-cloud/storage
```

## 用法

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

此外，您可以选择提供 `storageOptions` 参数，以指定您的存储选项，以及如果您不想使用应用默认凭据（ADC）作为默认方式时的其他身份验证方式。

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

const loader = new GoogleCloudStorageLoader({
  bucket: "my-bucket-123",
  file: "path/to/file.pdf",
  storageOptions: {
    keyFilename: "/path/to/keyfile.json",
  },
  unstructuredLoaderOptions: {
    apiUrl: "http://localhost:8000/general/v0/general",
    apiKey: "", // 此字段很快将变为必填项
  },
});

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/google_cloud_storage.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
