@zola_do/seaweed 0.1.9 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -0
- package/package.json +5 -2
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# @zola_do/seaweed
|
|
2
|
+
|
|
3
|
+
AWS S3-compatible object storage for NestJS (SeaweedFS, MinIO, or AWS S3).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install individually
|
|
9
|
+
npm install @zola_do/seaweed
|
|
10
|
+
|
|
11
|
+
# Or via meta package
|
|
12
|
+
npm install @zola_do/nestjs-shared
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Module Setup
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { Module } from '@nestjs/common';
|
|
21
|
+
import { StorageModule } from '@zola_do/seaweed';
|
|
22
|
+
|
|
23
|
+
@Module({
|
|
24
|
+
imports: [StorageModule],
|
|
25
|
+
})
|
|
26
|
+
export class AppModule {}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Uploading Files
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { Injectable } from '@nestjs/common';
|
|
33
|
+
import { StorageService } from '@zola_do/seaweed';
|
|
34
|
+
|
|
35
|
+
@Injectable()
|
|
36
|
+
export class FileService {
|
|
37
|
+
constructor(private readonly storageService: StorageService) {}
|
|
38
|
+
|
|
39
|
+
async upload(file: Express.Multer.File, bucketName: string) {
|
|
40
|
+
return await this.storageService.upload(file, bucketName);
|
|
41
|
+
// Returns FileInfo: { filepath, bucketName, contentType, originalname }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Downloading Files
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
await this.storageService.download(fileInfo, response);
|
|
50
|
+
// Streams file to Express Response with appropriate headers
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Presigned URLs
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// Upload
|
|
57
|
+
const uploadUrl = await this.storageService.generatePresignedUploadUrl(fileInfo);
|
|
58
|
+
|
|
59
|
+
// Download
|
|
60
|
+
const downloadUrl = await this.storageService.generatePresignedDownloadUrl(fileInfo);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Environment Variables
|
|
64
|
+
|
|
65
|
+
| Variable | Description |
|
|
66
|
+
|----------|-------------|
|
|
67
|
+
| `AWS_ACCESS_KEY_ID` | S3/MinIO access key |
|
|
68
|
+
| `AWS_SECRET_ACCESS_KEY` | S3/MinIO secret key |
|
|
69
|
+
| `AWS_ENDPOINT` | S3-compatible endpoint URL |
|
|
70
|
+
| `PRESIGNED_URL_EXPIRATION` | Presigned URL expiry in seconds |
|
|
71
|
+
|
|
72
|
+
## Exports
|
|
73
|
+
|
|
74
|
+
- `StorageModule` — Register the storage module
|
|
75
|
+
- `StorageService` — Upload, download, presigned URLs
|
|
76
|
+
- Types and exceptions for storage operations
|
|
77
|
+
|
|
78
|
+
## Related Packages
|
|
79
|
+
|
|
80
|
+
- [@zola_do/minio](../minio) — Alternative MinIO-specific module
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zola_do/seaweed",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "AWS S3-compatible storage for NestJS",
|
|
5
5
|
"author": "zolaDO",
|
|
6
6
|
"license": "ISC",
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
"files": [
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
19
22
|
"scripts": {
|
|
20
23
|
"build": "rimraf dist && tsc",
|
|
21
24
|
"prepublishOnly": "npm run build"
|