• Import from "@langchain/community/document_loaders/web/s3" instead. This entrypoint will be removed in 0.3.0.

A class that extends the BaseDocumentLoader class. It represents a document loader for loading files from an S3 bucket.

const loader = new S3Loader({
bucket: "my-document-bucket-123",
key: "AccountingOverview.pdf",
s3Config: {
region: "us-east-1",
credentials: {
accessKeyId: "<YourAccessKeyId>",
secretAccessKey: "<YourSecretAccessKey>",
},
},
unstructuredAPIURL: "<YourUnstructuredAPIURL>",
unstructuredAPIKey: "<YourUnstructuredAPIKey>",
});
const docs = await loader.load();

Hierarchy (view full)

Constructors

Methods

Constructors

Methods

  • Loads the file from the S3 bucket, saves it to a temporary directory, and then uses the UnstructuredLoader to load the file as a document.

    Returns Promise<Document<Record<string, any>>[]>

    An array of Document objects representing the loaded documents.

  • Parameters

    • Optionalsplitter: BaseDocumentTransformer<DocumentInterface<Record<string, any>>[], DocumentInterface<Record<string, any>>[]>

    Returns Promise<Document<Record<string, any>>[]>

    A Promise that resolves with an array of Document instances, each split according to the provided TextSplitter.

    Use this.load() and splitter.splitDocuments() individually. Loads the documents and splits them using a specified text splitter.