@zola_do/seaweed 0.2.7 → 0.2.9
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 +15 -15
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/services/seaweed.zola-object-storage.d.ts +11 -6
- package/dist/services/seaweed.zola-object-storage.js.map +1 -1
- package/package.json +1 -1
- package/dist/zola-object-storage.d.ts +0 -19
- package/dist/zola-object-storage.js +0 -5
- package/dist/zola-object-storage.js.map +0 -1
package/README.md
CHANGED
|
@@ -47,8 +47,8 @@ AWS_REGION=us-east-1
|
|
|
47
47
|
### 2. Register Module
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
|
-
import { Module } from
|
|
51
|
-
import { StorageModule } from
|
|
50
|
+
import { Module } from '@nestjs/common';
|
|
51
|
+
import { StorageModule } from '@zola_do/seaweed';
|
|
52
52
|
|
|
53
53
|
@Module({
|
|
54
54
|
imports: [StorageModule],
|
|
@@ -59,8 +59,8 @@ export class AppModule {}
|
|
|
59
59
|
### 3. Use Storage Service
|
|
60
60
|
|
|
61
61
|
```typescript
|
|
62
|
-
import { Injectable } from
|
|
63
|
-
import { StorageService } from
|
|
62
|
+
import { Injectable } from '@nestjs/common';
|
|
63
|
+
import { StorageService } from '@zola_do/seaweed';
|
|
64
64
|
|
|
65
65
|
@Injectable()
|
|
66
66
|
export class FileService {
|
|
@@ -219,15 +219,15 @@ async getDownloadUrl(fileInfo: FileInfo): Promise<string> {
|
|
|
219
219
|
// Server generates URL
|
|
220
220
|
const { presignedUrl, file } =
|
|
221
221
|
await this.storageService.generatePresignedUploadUrl({
|
|
222
|
-
originalname:
|
|
223
|
-
contentType:
|
|
222
|
+
originalname: 'document.pdf',
|
|
223
|
+
contentType: 'application/pdf',
|
|
224
224
|
});
|
|
225
225
|
|
|
226
226
|
// Client uploads directly
|
|
227
227
|
fetch(presignedUrl, {
|
|
228
|
-
method:
|
|
228
|
+
method: 'PUT',
|
|
229
229
|
body: fileBuffer,
|
|
230
|
-
headers: {
|
|
230
|
+
headers: { 'Content-Type': 'application/pdf' },
|
|
231
231
|
});
|
|
232
232
|
```
|
|
233
233
|
|
|
@@ -247,12 +247,12 @@ interface FileInfo {
|
|
|
247
247
|
Implement a custom storage provider:
|
|
248
248
|
|
|
249
249
|
```typescript
|
|
250
|
-
import { S3, FileInfo } from
|
|
250
|
+
import { S3, FileInfo } from '@zola_do/seaweed';
|
|
251
251
|
|
|
252
252
|
class CustomS3Provider extends S3 {
|
|
253
253
|
constructor() {
|
|
254
254
|
super({
|
|
255
|
-
region:
|
|
255
|
+
region: 'custom-region',
|
|
256
256
|
credentials: {
|
|
257
257
|
accessKeyId: process.env.CUSTOM_KEY!,
|
|
258
258
|
secretAccessKey: process.env.CUSTOM_SECRET!,
|
|
@@ -373,16 +373,16 @@ class FileNotFoundException extends NotFoundException {
|
|
|
373
373
|
Subpath imports are recommended for tree-shaking:
|
|
374
374
|
|
|
375
375
|
```typescript
|
|
376
|
-
import { StorageModule } from
|
|
377
|
-
import { StorageService, AwsS3 } from
|
|
378
|
-
import type { FileInfo } from
|
|
379
|
-
import { FileNotFoundException } from
|
|
376
|
+
import { StorageModule } from '@zola_do/seaweed/module';
|
|
377
|
+
import { StorageService, AwsS3 } from '@zola_do/seaweed/services';
|
|
378
|
+
import type { FileInfo } from '@zola_do/seaweed/types';
|
|
379
|
+
import { FileNotFoundException } from '@zola_do/seaweed/exceptions';
|
|
380
380
|
```
|
|
381
381
|
|
|
382
382
|
Root import is supported for backward compatibility:
|
|
383
383
|
|
|
384
384
|
```typescript
|
|
385
|
-
import { StorageModule, StorageService, FileInfo } from
|
|
385
|
+
import { StorageModule, StorageService, FileInfo } from '@zola_do/seaweed';
|
|
386
386
|
```
|
|
387
387
|
|
|
388
388
|
## Troubleshooting
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./zola-object-storage"), exports);
|
|
18
17
|
__exportStar(require("./storage.module"), exports);
|
|
19
18
|
__exportStar(require("./types"), exports);
|
|
20
19
|
__exportStar(require("./services/storage.service"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,0CAAwB;AACxB,6DAA2C;AAC3C,yEAAuD;AACvD,+CAA6B"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { ZolaObjectStorage, ZolaStoredFileRef } from '../zola-object-storage';
|
|
2
1
|
import { StorageService } from './storage.service';
|
|
3
|
-
export
|
|
2
|
+
export type SeaweedStoredFileRef = {
|
|
3
|
+
filepath: string;
|
|
4
|
+
bucketName: string;
|
|
5
|
+
contentType: string;
|
|
6
|
+
originalname: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class SeaweedZolaObjectStorage {
|
|
4
9
|
private readonly storage;
|
|
5
10
|
constructor(storage: StorageService);
|
|
6
|
-
uploadFile(file: Express.Multer.File, bucketName: string, _metaData?: Record<string, string>): Promise<
|
|
7
|
-
uploadBuffer(buffer: Buffer, originalname: string, mimetype: string, bucketName: string): Promise<
|
|
11
|
+
uploadFile(file: Express.Multer.File, bucketName: string, _metaData?: Record<string, string>): Promise<SeaweedStoredFileRef>;
|
|
12
|
+
uploadBuffer(buffer: Buffer, originalname: string, mimetype: string, bucketName: string): Promise<SeaweedStoredFileRef>;
|
|
8
13
|
generatePresignedUploadUrl(fileInfo: {
|
|
9
14
|
originalname: string;
|
|
10
15
|
contentType?: string;
|
|
11
16
|
}, bucketName: string): Promise<{
|
|
12
17
|
presignedUrl: string;
|
|
13
|
-
file:
|
|
18
|
+
file: SeaweedStoredFileRef;
|
|
14
19
|
}>;
|
|
15
|
-
generatePresignedDownloadUrl(fileInfo: Pick<
|
|
20
|
+
generatePresignedDownloadUrl(fileInfo: Pick<SeaweedStoredFileRef, 'bucketName' | 'filepath' | 'contentType' | 'originalname'>): Promise<string>;
|
|
16
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seaweed.zola-object-storage.js","sourceRoot":"","sources":["../../src/services/seaweed.zola-object-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;
|
|
1
|
+
{"version":3,"file":"seaweed.zola-object-storage.js","sourceRoot":"","sources":["../../src/services/seaweed.zola-object-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,uDAAmD;AAc5C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACnC,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,UAAU,CACR,IAAyB,EACzB,UAAkB,EAClB,SAAkC;QAElC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CACxB,IAAI,EACJ,UAAU,CACsB,CAAC;IACrC,CAAC;IAED,YAAY,CACV,MAAc,EACd,YAAoB,EACpB,QAAgB,EAChB,UAAkB;QAElB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAC9B,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,UAAU,CACsB,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,0BAA0B,CAC9B,QAAwD,EACxD,UAAkB;;QAElB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,iCAAiC,CAAC;YAClE,YAAY,EAAE,QAAQ,CAAC,YAAY;YACnC,WAAW,EAAE,MAAA,QAAQ,CAAC,WAAW,mCAAI,0BAA0B;YAC/D,UAAU;YACV,QAAQ,EAAE,EAAE;SACb,CAAC,CAAC;QACH,OAAO;YACL,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,IAAI,EAAE,MAAM,CAAC,IAA4B;SAC1C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,4BAA4B,CAChC,QAGC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;CACF,CAAA;AApDY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAE2B,gCAAc;GADzC,wBAAwB,CAoDpC"}
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type ZolaStoredFileRef = {
|
|
2
|
-
filepath: string;
|
|
3
|
-
bucketName: string;
|
|
4
|
-
contentType: string;
|
|
5
|
-
originalname: string;
|
|
6
|
-
};
|
|
7
|
-
export interface ZolaObjectStorage {
|
|
8
|
-
uploadFile(file: Express.Multer.File, bucketName: string, metaData?: Record<string, string>): Promise<ZolaStoredFileRef>;
|
|
9
|
-
uploadBuffer(buffer: Buffer, originalname: string, mimetype: string, bucketName: string, metaData?: Record<string, string>): Promise<ZolaStoredFileRef>;
|
|
10
|
-
generatePresignedUploadUrl(fileInfo: {
|
|
11
|
-
originalname: string;
|
|
12
|
-
contentType?: string;
|
|
13
|
-
}, bucketName: string): Promise<{
|
|
14
|
-
presignedUrl: string;
|
|
15
|
-
file: ZolaStoredFileRef;
|
|
16
|
-
}>;
|
|
17
|
-
generatePresignedDownloadUrl(fileInfo: Pick<ZolaStoredFileRef, 'bucketName' | 'filepath' | 'contentType' | 'originalname'>): Promise<string>;
|
|
18
|
-
}
|
|
19
|
-
export declare const ZOLA_STORAGE_CONTRACT_VERSION: 1;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zola-object-storage.js","sourceRoot":"","sources":["../src/zola-object-storage.ts"],"names":[],"mappings":";;;AA4Ca,QAAA,6BAA6B,GAAG,CAAU,CAAC"}
|