@zola_do/seaweed
v0.1.10
Published
AWS S3-compatible storage for NestJS
Readme
@zola_do/seaweed
AWS S3-compatible object storage for NestJS (SeaweedFS, MinIO, or AWS S3).
Installation
# Install individually
npm install @zola_do/seaweed
# Or via meta package
npm install @zola_do/nestjs-sharedUsage
Module Setup
import { Module } from '@nestjs/common';
import { StorageModule } from '@zola_do/seaweed';
@Module({
imports: [StorageModule],
})
export class AppModule {}Uploading Files
import { Injectable } from '@nestjs/common';
import { StorageService } from '@zola_do/seaweed';
@Injectable()
export class FileService {
constructor(private readonly storageService: StorageService) {}
async upload(file: Express.Multer.File, bucketName: string) {
return await this.storageService.upload(file, bucketName);
// Returns FileInfo: { filepath, bucketName, contentType, originalname }
}
}Downloading Files
await this.storageService.download(fileInfo, response);
// Streams file to Express Response with appropriate headersPresigned URLs
// Upload
const uploadUrl = await this.storageService.generatePresignedUploadUrl(fileInfo);
// Download
const downloadUrl = await this.storageService.generatePresignedDownloadUrl(fileInfo);Environment Variables
| Variable | Description |
|----------|-------------|
| AWS_ACCESS_KEY_ID | S3/MinIO access key |
| AWS_SECRET_ACCESS_KEY | S3/MinIO secret key |
| AWS_ENDPOINT | S3-compatible endpoint URL |
| PRESIGNED_URL_EXPIRATION | Presigned URL expiry in seconds |
Exports
StorageModule— Register the storage moduleStorageService— Upload, download, presigned URLs- Types and exceptions for storage operations
Related Packages
- @zola_do/minio — Alternative MinIO-specific module
