Skip to main content

Google Cloud Storage

Compatibility

Only available on Node.js.

This covers how to load a Google Cloud Storage File into LangChain documents.

Setup

To use this loader, you'll need to have Unstructured already set up and ready to use at an available URL endpoint. It can also be configured to run locally.

See the docs here for information on how to do that.

You'll also need to install the official Google Cloud Storage SDK:

npm install @langchain/community @langchain/core @google-cloud/storage

Usage

Once Unstructured is configured, you can use the Google Cloud Storage loader to load files and then convert them into a Document.

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: "", // this will be soon required
},
});

const docs = await loader.load();

console.log(docs);

API Reference:


Was this page helpful?


You can also leave detailed feedback on GitHub.