@nathapp/nestjs-storage 2.1.5 → 3.0.0-rc.4
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 +129 -9
- package/dist/module/storage.module.js.map +1 -1
- package/dist/providers/azure-blob-storage.d.ts +22 -0
- package/dist/providers/azure-blob-storage.js +169 -0
- package/dist/providers/azure-blob-storage.js.map +1 -0
- package/dist/providers/base-storage.d.ts +3 -5
- package/dist/providers/base-storage.js +4 -1
- package/dist/providers/base-storage.js.map +1 -1
- package/dist/providers/dropbox-storage.d.ts +3 -5
- package/dist/providers/dropbox-storage.js +84 -151
- package/dist/providers/dropbox-storage.js.map +1 -1
- package/dist/providers/gcs-storage.d.ts +22 -0
- package/dist/providers/gcs-storage.js +132 -0
- package/dist/providers/gcs-storage.js.map +1 -0
- package/dist/providers/gdrive-storage.d.ts +3 -5
- package/dist/providers/gdrive-storage.js +109 -192
- package/dist/providers/gdrive-storage.js.map +1 -1
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/local-storage.d.ts +5 -6
- package/dist/providers/local-storage.js +68 -128
- package/dist/providers/local-storage.js.map +1 -1
- package/dist/providers/oss-storage.d.ts +1 -1
- package/dist/providers/oss-storage.js +10 -4
- package/dist/providers/oss-storage.js.map +1 -1
- package/dist/providers/provider-factory.js +8 -0
- package/dist/providers/provider-factory.js.map +1 -1
- package/dist/providers/s3-base-storage.d.ts +7 -10
- package/dist/providers/s3-base-storage.js +50 -95
- package/dist/providers/s3-base-storage.js.map +1 -1
- package/dist/service/storage-service.d.ts +3 -0
- package/dist/service/storage-service.js +25 -4
- package/dist/service/storage-service.js.map +1 -1
- package/dist/types/capabilities.d.ts +15 -0
- package/dist/types/capabilities.js +3 -0
- package/dist/types/capabilities.js.map +1 -0
- package/dist/types/clients.d.ts +216 -0
- package/dist/types/clients.js +3 -0
- package/dist/types/clients.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/options.d.ts +28 -2
- package/dist/types/options.js +2 -0
- package/dist/types/options.js.map +1 -1
- package/dist/types/storage.d.ts +7 -2
- package/dist/util/imageUtils.js +9 -3
- package/dist/util/imageUtils.js.map +1 -1
- package/docs/20260215-fix-plan-storage.md +66 -0
- package/docs/20260215-implementation-report.md +33 -0
- package/docs/20260215-plan-storage-providers.md +207 -0
- package/docs/20260215-review-storage-postfix.md +278 -0
- package/docs/20260215-review-storage.md +284 -0
- package/docs/20260216-plan-storage-a-minus.md +41 -0
- package/docs/20260216-review-storage-postfix2.md +102 -0
- package/docs/gdrive-security.md +222 -0
- package/docs/provider-capabilities.md +448 -0
- package/package.json +8 -3
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
# Storage Provider Capabilities Matrix
|
|
2
|
+
|
|
3
|
+
This document outlines which storage methods and capabilities are supported by each provider in the @nathapp/nestjs-storage package.
|
|
4
|
+
|
|
5
|
+
## Provider Overview
|
|
6
|
+
|
|
7
|
+
The storage module supports the following providers:
|
|
8
|
+
- **LOCAL** - Local filesystem storage
|
|
9
|
+
- **NFS** - Network file system (placeholder implementation)
|
|
10
|
+
- **S3** - Amazon S3 and S3-compatible storage (MinIO, DigitalOcean Spaces, etc.)
|
|
11
|
+
- **R2** - Cloudflare R2 (S3-compatible)
|
|
12
|
+
- **OSS** - Alibaba Cloud Object Storage Service
|
|
13
|
+
- **GDRIVE** - Google Drive
|
|
14
|
+
- **DROPBOX** - Dropbox
|
|
15
|
+
- **AZURE_BLOB** - Microsoft Azure Blob Storage
|
|
16
|
+
- **GCS** - Google Cloud Storage
|
|
17
|
+
|
|
18
|
+
## Base Storage Methods
|
|
19
|
+
|
|
20
|
+
All providers inherit from `BaseStorage` and must implement these core methods:
|
|
21
|
+
|
|
22
|
+
| Method | Description | All Providers |
|
|
23
|
+
|--------|-------------|---------------|
|
|
24
|
+
| `putFile(path, data)` | Upload a file | ✅ |
|
|
25
|
+
| `getFileOrFolder(fileId)` | Get file/folder metadata | ✅ |
|
|
26
|
+
| `readFile(fileId)` | Read file as stream | ✅ |
|
|
27
|
+
| `deleteFileOrFolder(fileId)` | Delete file or folder | ✅ |
|
|
28
|
+
| `moveFileOrFolder(fileId, newPath)` | Move file/folder | ✅ |
|
|
29
|
+
| `renameFileOrFolder(fileId, newName)` | Rename file/folder | ✅ |
|
|
30
|
+
| `createFolder(path)` | Create a folder | ✅ |
|
|
31
|
+
| `readFolder(folderId)` | List folder contents | ✅ |
|
|
32
|
+
| `getObjectUrl(fileId)` | Get public URL | ✅ |
|
|
33
|
+
| `getSignedUrl(fileId, expires?)` | Get signed/temporary URL | ✅ |
|
|
34
|
+
|
|
35
|
+
**Note:** While all providers must implement these methods, some providers (notably NFS) may throw `NotImplementedError` for certain operations. See provider-specific details below.
|
|
36
|
+
|
|
37
|
+
## Optional Capabilities
|
|
38
|
+
|
|
39
|
+
### Stream Capability (`IStreamCapable`)
|
|
40
|
+
|
|
41
|
+
Supports HTTP range requests for partial file reads (HTTP 206 Partial Content).
|
|
42
|
+
|
|
43
|
+
| Provider | Supports Streaming | Notes |
|
|
44
|
+
|----------|-------------------|-------|
|
|
45
|
+
| LOCAL | ✅ | Full support |
|
|
46
|
+
| NFS | ❌ | Throws `NotImplementedError` |
|
|
47
|
+
| S3 | ✅ | Full support |
|
|
48
|
+
| R2 | ✅ | Full support (S3-compatible) |
|
|
49
|
+
| OSS | ✅ | Full support |
|
|
50
|
+
| GDRIVE | ✅ | Full support |
|
|
51
|
+
| DROPBOX | ✅ | Full support |
|
|
52
|
+
| AZURE_BLOB | ✅ | Full support |
|
|
53
|
+
| GCS | ✅ | Full support |
|
|
54
|
+
|
|
55
|
+
**Method signature:**
|
|
56
|
+
```typescript
|
|
57
|
+
streamFile(fileId: string, range: string): Promise<PartialStream>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Example usage:**
|
|
61
|
+
```typescript
|
|
62
|
+
const result = await storage.streamFile('file-id', 'bytes=0-1023');
|
|
63
|
+
// Returns: { stream: ReadableStream, headers: { contentRange, contentLength, ... } }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Client Upload Capability (`IClientUploadCapable`)
|
|
67
|
+
|
|
68
|
+
Allows clients to upload files directly to the storage provider without proxying through your server.
|
|
69
|
+
|
|
70
|
+
| Provider | Supports Client Upload | Notes |
|
|
71
|
+
|----------|----------------------|-------|
|
|
72
|
+
| LOCAL | ❌ | N/A |
|
|
73
|
+
| NFS | ❌ | Throws `NotImplementedError` |
|
|
74
|
+
| S3 | ❌ | Not implemented (could be added via presigned POST) |
|
|
75
|
+
| R2 | ❌ | Not implemented |
|
|
76
|
+
| OSS | ✅ | Full support with STS tokens |
|
|
77
|
+
| GDRIVE | ❌ | Not implemented |
|
|
78
|
+
| DROPBOX | ❌ | Not implemented |
|
|
79
|
+
| AZURE_BLOB | ❌ | Not implemented (could be added via SAS tokens) |
|
|
80
|
+
| GCS | ❌ | Not implemented (could be added via signed URLs) |
|
|
81
|
+
|
|
82
|
+
**Method signatures:**
|
|
83
|
+
```typescript
|
|
84
|
+
getClientUploadCredential(option: ClientCredentialOptions): Promise<any>
|
|
85
|
+
resolveClientUploadCallback(payload: ClientUploadCallbackPayload, options?: ClientUploadCallbackOptions): Promise<ClientUploadCallbackResult>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Example usage (OSS only):**
|
|
89
|
+
```typescript
|
|
90
|
+
// Get credentials for client-side upload
|
|
91
|
+
const credentials = await storage.getClientUploadCredential({
|
|
92
|
+
expiration: new Date(Date.now() + 3600000).toISOString(),
|
|
93
|
+
callbackUrl: 'https://api.example.com/upload-callback',
|
|
94
|
+
directory: 'uploads/',
|
|
95
|
+
maxDatalength: 10485760, // 10MB
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Client uploads directly to OSS using credentials
|
|
99
|
+
// ...
|
|
100
|
+
|
|
101
|
+
// When OSS calls back, verify the upload
|
|
102
|
+
const result = await storage.resolveClientUploadCallback({
|
|
103
|
+
headers: req.headers,
|
|
104
|
+
payload: req.body,
|
|
105
|
+
url: req.url,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (result.valid) {
|
|
109
|
+
console.log('File uploaded:', result.url);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Image Processing Capability (`IImageProcessingCapable`)
|
|
114
|
+
|
|
115
|
+
Server-side image transformations (resize, crop, format conversion, quality adjustment).
|
|
116
|
+
|
|
117
|
+
| Provider | Supports Image Processing | Notes |
|
|
118
|
+
|----------|--------------------------|-------|
|
|
119
|
+
| LOCAL | ❌ | N/A |
|
|
120
|
+
| NFS | ❌ | Throws `NotImplementedError` |
|
|
121
|
+
| S3 | ❌ | Not implemented (use AWS Lambda or third-party service) |
|
|
122
|
+
| R2 | ❌ | Not implemented (use Cloudflare Images) |
|
|
123
|
+
| OSS | ✅ | Full support via OSS Image Processing |
|
|
124
|
+
| GDRIVE | ❌ | Not implemented |
|
|
125
|
+
| DROPBOX | ❌ | Not implemented |
|
|
126
|
+
| AZURE_BLOB | ❌ | Not implemented (use Azure Functions) |
|
|
127
|
+
| GCS | ❌ | Not implemented (use Cloud Functions) |
|
|
128
|
+
|
|
129
|
+
**Method signature:**
|
|
130
|
+
```typescript
|
|
131
|
+
preprocessImage(sourceFileId: string, targetFileId: string, options: PreprocessImageOptions): Promise<PreprocessImageResult>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Example usage (OSS only):**
|
|
135
|
+
```typescript
|
|
136
|
+
const result = await storage.preprocessImage(
|
|
137
|
+
'source/image.jpg',
|
|
138
|
+
'processed/image-thumb.webp',
|
|
139
|
+
{
|
|
140
|
+
format: 'webp',
|
|
141
|
+
width: 300,
|
|
142
|
+
height: 300,
|
|
143
|
+
quality: 80,
|
|
144
|
+
targetBucket: 'my-bucket',
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
if (result.success) {
|
|
149
|
+
console.log('Image processed:', result.targetFileId);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Provider-Specific Details
|
|
154
|
+
|
|
155
|
+
### LOCAL Storage
|
|
156
|
+
|
|
157
|
+
**Fully implemented methods:**
|
|
158
|
+
- All base storage methods
|
|
159
|
+
- `streamFile` for range requests
|
|
160
|
+
|
|
161
|
+
**Storage location:** Local filesystem at configured root path
|
|
162
|
+
|
|
163
|
+
**Use cases:** Development, testing, small deployments without cloud dependencies
|
|
164
|
+
|
|
165
|
+
**Limitations:**
|
|
166
|
+
- No built-in CDN support
|
|
167
|
+
- Limited scalability
|
|
168
|
+
- No redundancy/replication
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### NFS Storage
|
|
173
|
+
|
|
174
|
+
**Status:** Placeholder implementation
|
|
175
|
+
|
|
176
|
+
**Implemented methods:** None (all methods throw `NotImplementedError`)
|
|
177
|
+
|
|
178
|
+
**Purpose:** Reserved for future network file system support
|
|
179
|
+
|
|
180
|
+
**Usage:** Not recommended for production use
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
### S3 / R2 Storage
|
|
185
|
+
|
|
186
|
+
**Fully implemented methods:**
|
|
187
|
+
- All base storage methods
|
|
188
|
+
- `streamFile` for range requests
|
|
189
|
+
|
|
190
|
+
**S3 compatibility:** Works with any S3-compatible storage:
|
|
191
|
+
- Amazon S3
|
|
192
|
+
- Cloudflare R2
|
|
193
|
+
- MinIO
|
|
194
|
+
- DigitalOcean Spaces
|
|
195
|
+
- Wasabi
|
|
196
|
+
- Backblaze B2 (with S3-compatible API)
|
|
197
|
+
|
|
198
|
+
**Configuration differences:**
|
|
199
|
+
- S3: Uses AWS endpoints
|
|
200
|
+
- R2: Uses Cloudflare endpoints (`https://<account-id>.r2.cloudflarestorage.com`)
|
|
201
|
+
|
|
202
|
+
**Use cases:** Production-grade object storage with high availability
|
|
203
|
+
|
|
204
|
+
**Features:**
|
|
205
|
+
- Signed URLs with configurable expiration
|
|
206
|
+
- Range requests for efficient streaming
|
|
207
|
+
- Multi-region support
|
|
208
|
+
- Lifecycle policies
|
|
209
|
+
- Versioning support
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
### OSS Storage
|
|
214
|
+
|
|
215
|
+
**Fully implemented methods:**
|
|
216
|
+
- All base storage methods
|
|
217
|
+
- `streamFile` for range requests
|
|
218
|
+
- `getClientUploadCredential` for direct client uploads
|
|
219
|
+
- `resolveClientUploadCallback` for upload verification
|
|
220
|
+
- `preprocessImage` for server-side image processing
|
|
221
|
+
|
|
222
|
+
**Provider:** Alibaba Cloud Object Storage Service
|
|
223
|
+
|
|
224
|
+
**Unique capabilities:**
|
|
225
|
+
- Built-in image processing (resize, crop, format conversion, watermarking)
|
|
226
|
+
- Client-side upload with STS tokens
|
|
227
|
+
- Upload callback verification with signature validation
|
|
228
|
+
|
|
229
|
+
**Use cases:**
|
|
230
|
+
- Applications deployed in China (better performance/compliance)
|
|
231
|
+
- Applications requiring built-in image processing
|
|
232
|
+
- Client-side uploads without server proxying
|
|
233
|
+
|
|
234
|
+
**Security features:**
|
|
235
|
+
- RSA-MD5 signature verification for upload callbacks
|
|
236
|
+
- Public key validation against Alibaba CDN
|
|
237
|
+
- Base64-encoded authorization headers
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
### GDrive Storage
|
|
242
|
+
|
|
243
|
+
**Fully implemented methods:**
|
|
244
|
+
- All base storage methods
|
|
245
|
+
- `streamFile` for range requests
|
|
246
|
+
|
|
247
|
+
**Provider:** Google Drive API v3
|
|
248
|
+
|
|
249
|
+
**Authentication:** OAuth 2.0 with refresh tokens
|
|
250
|
+
|
|
251
|
+
**Use cases:**
|
|
252
|
+
- Integration with Google Workspace
|
|
253
|
+
- User-facing file storage with Google Drive UI
|
|
254
|
+
- Collaborative document workflows
|
|
255
|
+
|
|
256
|
+
**Limitations:**
|
|
257
|
+
- Requires OAuth setup and refresh token management
|
|
258
|
+
- API rate limits (per-user quotas)
|
|
259
|
+
- No built-in CDN (files served through Google Drive URLs)
|
|
260
|
+
|
|
261
|
+
**Security:** See [gdrive-security.md](./gdrive-security.md) for refresh token best practices
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
### Dropbox Storage
|
|
266
|
+
|
|
267
|
+
**Fully implemented methods:**
|
|
268
|
+
- All base storage methods
|
|
269
|
+
- `streamFile` for range requests
|
|
270
|
+
|
|
271
|
+
**Provider:** Dropbox API v2
|
|
272
|
+
|
|
273
|
+
**Authentication:** OAuth 2.0 with refresh tokens
|
|
274
|
+
|
|
275
|
+
**Use cases:**
|
|
276
|
+
- Integration with Dropbox ecosystem
|
|
277
|
+
- User-facing file storage
|
|
278
|
+
- Cross-device file synchronization
|
|
279
|
+
|
|
280
|
+
**Limitations:**
|
|
281
|
+
- Requires OAuth setup
|
|
282
|
+
- API rate limits
|
|
283
|
+
- Storage quota depends on Dropbox plan
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
### Azure Blob Storage
|
|
288
|
+
|
|
289
|
+
**Fully implemented methods:**
|
|
290
|
+
- All base storage methods
|
|
291
|
+
- `streamFile` for range requests
|
|
292
|
+
|
|
293
|
+
**Provider:** Microsoft Azure Blob Storage
|
|
294
|
+
|
|
295
|
+
**Authentication options:**
|
|
296
|
+
- Connection string
|
|
297
|
+
- Account name + account key
|
|
298
|
+
- SAS token
|
|
299
|
+
|
|
300
|
+
**Use cases:**
|
|
301
|
+
- Azure-native applications
|
|
302
|
+
- Enterprise Windows/Microsoft-centric environments
|
|
303
|
+
- Large-scale blob storage
|
|
304
|
+
|
|
305
|
+
**Features:**
|
|
306
|
+
- Multiple access tiers (Hot, Cool, Archive)
|
|
307
|
+
- Lifecycle management
|
|
308
|
+
- Soft delete and versioning
|
|
309
|
+
- Integration with Azure CDN
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
### GCS Storage
|
|
314
|
+
|
|
315
|
+
**Fully implemented methods:**
|
|
316
|
+
- All base storage methods
|
|
317
|
+
- `streamFile` for range requests
|
|
318
|
+
|
|
319
|
+
**Provider:** Google Cloud Storage
|
|
320
|
+
|
|
321
|
+
**Authentication options:**
|
|
322
|
+
- Service account key file
|
|
323
|
+
- Application Default Credentials (ADC)
|
|
324
|
+
- Explicit credentials object
|
|
325
|
+
|
|
326
|
+
**Use cases:**
|
|
327
|
+
- Google Cloud Platform applications
|
|
328
|
+
- Multi-region/dual-region storage
|
|
329
|
+
- Integration with other GCP services
|
|
330
|
+
|
|
331
|
+
**Features:**
|
|
332
|
+
- Multiple storage classes
|
|
333
|
+
- Object lifecycle management
|
|
334
|
+
- Versioning and retention policies
|
|
335
|
+
- Integration with Cloud CDN
|
|
336
|
+
|
|
337
|
+
## Error Handling
|
|
338
|
+
|
|
339
|
+
### NotImplementedError
|
|
340
|
+
|
|
341
|
+
When a method is not supported by a provider, it will throw a `NotImplementedError` or generic `Error` with message "Method not implemented."
|
|
342
|
+
|
|
343
|
+
**Example:**
|
|
344
|
+
```typescript
|
|
345
|
+
try {
|
|
346
|
+
const nfsStorage = new NFSStorage(config);
|
|
347
|
+
await nfsStorage.putFile('test.txt', Buffer.from('hello'));
|
|
348
|
+
} catch (error) {
|
|
349
|
+
if (error.message === 'Method not implemented.') {
|
|
350
|
+
console.error('This provider does not support putFile');
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Checking Capabilities at Runtime
|
|
356
|
+
|
|
357
|
+
Use type guards and duck typing to check for capabilities:
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
import { BaseStorage } from '@nathapp/nestjs-storage';
|
|
361
|
+
import { IStreamCapable, IClientUploadCapable, IImageProcessingCapable } from '@nathapp/nestjs-storage';
|
|
362
|
+
|
|
363
|
+
function isStreamCapable(storage: BaseStorage): storage is BaseStorage & IStreamCapable {
|
|
364
|
+
return 'streamFile' in storage && typeof storage.streamFile === 'function';
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function isClientUploadCapable(storage: BaseStorage): storage is BaseStorage & IClientUploadCapable {
|
|
368
|
+
return 'getClientUploadCredential' in storage && typeof storage.getClientUploadCredential === 'function';
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function isImageProcessingCapable(storage: BaseStorage): storage is BaseStorage & IImageProcessingCapable {
|
|
372
|
+
return 'preprocessImage' in storage && typeof storage.preprocessImage === 'function';
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Usage
|
|
376
|
+
const storage = getStorageProvider();
|
|
377
|
+
|
|
378
|
+
if (isStreamCapable(storage)) {
|
|
379
|
+
await storage.streamFile('file-id', 'bytes=0-1023');
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (isImageProcessingCapable(storage)) {
|
|
383
|
+
await storage.preprocessImage('source.jpg', 'thumb.jpg', { width: 100, height: 100 });
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Capability Summary Table
|
|
388
|
+
|
|
389
|
+
| Provider | Base Methods | Streaming | Client Upload | Image Processing |
|
|
390
|
+
|----------|--------------|-----------|---------------|------------------|
|
|
391
|
+
| LOCAL | ✅ | ✅ | ❌ | ❌ |
|
|
392
|
+
| NFS | ❌ | ❌ | ❌ | ❌ |
|
|
393
|
+
| S3 | ✅ | ✅ | ❌ | ❌ |
|
|
394
|
+
| R2 | ✅ | ✅ | ❌ | ❌ |
|
|
395
|
+
| OSS | ✅ | ✅ | ✅ | ✅ |
|
|
396
|
+
| GDRIVE | ✅ | ✅ | ❌ | ❌ |
|
|
397
|
+
| DROPBOX | ✅ | ✅ | ❌ | ❌ |
|
|
398
|
+
| AZURE_BLOB | ✅ | ✅ | ❌ | ❌ |
|
|
399
|
+
| GCS | ✅ | ✅ | ❌ | ❌ |
|
|
400
|
+
|
|
401
|
+
**Legend:**
|
|
402
|
+
- ✅ Fully implemented and tested
|
|
403
|
+
- ❌ Not implemented (throws `NotImplementedError` or equivalent)
|
|
404
|
+
|
|
405
|
+
## Migration Notes
|
|
406
|
+
|
|
407
|
+
### Migrating Between Providers
|
|
408
|
+
|
|
409
|
+
When migrating from one storage provider to another, consider these compatibility factors:
|
|
410
|
+
|
|
411
|
+
1. **Base methods** - All production providers (except NFS) support the same base operations
|
|
412
|
+
2. **Streaming** - All production providers support range requests
|
|
413
|
+
3. **Client upload** - Only OSS supports this; you'll need server-side uploads for other providers
|
|
414
|
+
4. **Image processing** - Only OSS has built-in support; use external services for others (imgix, Cloudinary, etc.)
|
|
415
|
+
|
|
416
|
+
### Provider Selection Guide
|
|
417
|
+
|
|
418
|
+
Choose your storage provider based on:
|
|
419
|
+
|
|
420
|
+
| Requirement | Recommended Providers |
|
|
421
|
+
|-------------|----------------------|
|
|
422
|
+
| Global CDN integration | S3, GCS, Azure Blob |
|
|
423
|
+
| China deployment | OSS |
|
|
424
|
+
| Built-in image processing | OSS |
|
|
425
|
+
| Client-side uploads | OSS (or implement presigned URLs for S3/GCS/Azure) |
|
|
426
|
+
| Google Workspace integration | GDrive |
|
|
427
|
+
| Dropbox integration | Dropbox |
|
|
428
|
+
| Cost optimization | R2 (no egress fees), S3 (with lifecycle policies) |
|
|
429
|
+
| Development/testing | LOCAL |
|
|
430
|
+
|
|
431
|
+
## Future Capabilities
|
|
432
|
+
|
|
433
|
+
Potential future enhancements:
|
|
434
|
+
|
|
435
|
+
- **Presigned POST for S3/GCS/Azure** - Enable client-side uploads
|
|
436
|
+
- **Lifecycle management** - Automated object archival and deletion
|
|
437
|
+
- **Versioning support** - Retrieve and restore previous versions
|
|
438
|
+
- **Metadata management** - Custom metadata and tagging
|
|
439
|
+
- **Batch operations** - Upload/delete multiple files in one request
|
|
440
|
+
- **Multipart upload** - Efficient large file uploads with resumption
|
|
441
|
+
- **Cross-region replication** - Automatic replication across regions
|
|
442
|
+
|
|
443
|
+
## References
|
|
444
|
+
|
|
445
|
+
- [Base Storage Class](../lib/providers/base-storage.ts)
|
|
446
|
+
- [Capability Interfaces](../lib/types/capabilities.ts)
|
|
447
|
+
- [Storage Options](../lib/types/options.ts)
|
|
448
|
+
- [GDrive Security Best Practices](./gdrive-security.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathapp/nestjs-storage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-rc.4",
|
|
4
4
|
"description": "Nestjs Storage Implementation",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist/ .turbo/",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@azure/storage-blob": "^12.23.0",
|
|
21
|
+
"@google-cloud/storage": "^7.15.0",
|
|
21
22
|
"@types/ali-oss": "^6.16.11",
|
|
22
23
|
"ali-oss": "^6.20.0",
|
|
23
24
|
"aws-sdk": "^2.1661.0",
|
|
@@ -31,16 +32,17 @@
|
|
|
31
32
|
"lib": "lib"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@nathapp/nestjs-common": "^
|
|
35
|
+
"@nathapp/nestjs-common": "^3.0.0-rc.4",
|
|
35
36
|
"sharp": "^0.33.5",
|
|
36
37
|
"zod": "^3.23.8"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"@nathapp/auth": "^1.0.2",
|
|
40
|
-
"@nathapp/nestjs-common": "^
|
|
41
|
+
"@nathapp/nestjs-common": "^3.0.0-rc.4",
|
|
41
42
|
"@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
|
|
42
43
|
"@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
|
|
43
44
|
"@azure/storage-blob": "^12.23.0",
|
|
45
|
+
"@google-cloud/storage": "^7.15.0",
|
|
44
46
|
"ali-oss": "^6.20.0",
|
|
45
47
|
"aws-sdk": "^2.1661.0",
|
|
46
48
|
"googleapis": "^140.0.1"
|
|
@@ -49,6 +51,9 @@
|
|
|
49
51
|
"@azure/storage-blob": {
|
|
50
52
|
"optional": true
|
|
51
53
|
},
|
|
54
|
+
"@google-cloud/storage": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
52
57
|
"ali-oss": {
|
|
53
58
|
"optional": true
|
|
54
59
|
},
|