> For the complete documentation index, see [llms.txt](https://human-forge.gitbook.io/nestjs-seaweedfs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://human-forge.gitbook.io/nestjs-seaweedfs/quick-start.md).

# Quick Start

Get up and running with `nestjs-seaweedfs` in under 5 minutes.

## Prerequisites

* Node.js >= 18.0.0
* A running SeaweedFS instance (Filer + S3 Gateway)

## 1. Install the package

```bash
npm install nestjs-seaweedfs
```

> **Peer dependencies:** `@nestjs/common`, `@nestjs/core`, `reflect-metadata`, `rxjs` — these are typically already installed in any NestJS project.

## 2. Start SeaweedFS (Docker)

```bash
docker run -d \
  --name seaweedfs \
  -p 8888:8888 \
  -p 8333:8333 \
  -p 9333:9333 \
  chrislusf/seaweedfs:latest \
  filer -master=localhost:9333 -s3 -s3.port=8333
```

> This starts the Filer on port 8888 and the S3 Gateway on port 8333.

## 3. Configure the module

Create `src/app.module.ts`:

```typescript
import { Module } from '@nestjs/common';
import { SeaweedFsModule } from 'nestjs-seaweedfs';

@Module({
  imports: [
    SeaweedFsModule.forRoot({
      filer: {
        url: 'http://localhost:8888',
      },
      s3: {
        endpoint: 'http://localhost:8333',
        accessKeyId: 'your-access-key',
        secretAccessKey: 'your-secret-key',
        forcePathStyle: true,
        defaultBucket: 'my-bucket',
      },
    }),
  ],
})
export class AppModule {}
```

## 4. Upload your first file

Create `src/file.service.ts`:

```typescript
import { Injectable } from '@nestjs/common';
import { SeaweedFsService } from 'nestjs-seaweedfs';

@Injectable()
export class FileService {
  constructor(private readonly seaweed: SeaweedFsService) {}

  async uploadFile() {
    return this.seaweed.upload('/uploads/hello.txt', Buffer.from('Hello, SeaweedFS!'), {
      ttl: 86400,
      replication: '001',
    });
  }

  async downloadFile() {
    return this.seaweed.downloadToBuffer('/uploads/hello.txt');
  }
}
```

## 5. Verify

Run your NestJS application:

```bash
npm run start:dev
```

Then call your service method — the file will be uploaded to SeaweedFS via the Filer API.

## What's next?

* [Filer API](/nestjs-seaweedfs/filer-api.md) — Full Filer REST API operations
* [S3 API](/nestjs-seaweedfs/s3-api.md) — S3 Gateway operations including presigned URLs
* [Examples](https://github.com/bikky-kc013/nestjs-seaweedfs/tree/main/examples/README.md) — Complete controller examples


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://human-forge.gitbook.io/nestjs-seaweedfs/quick-start.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
