@zola_do/minio 0.2.4 → 0.2.6

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 CHANGED
@@ -1,7 +1,20 @@
1
1
  # @zola_do/minio
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@zola_do/minio.svg)](https://www.npmjs.com/package/@zola_do/minio)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@zola_do/minio.svg)](https://www.npmjs.com/package/@zola_do/minio)
5
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
6
+
3
7
  MinIO object storage integration for NestJS applications.
4
8
 
9
+ ## Overview
10
+
11
+ `@zola_do/minio` provides:
12
+
13
+ - **File Upload** — Direct upload with Multer or buffer
14
+ - **Presigned URLs** — Secure upload/download links
15
+ - **Bucket Management** — Multiple predefined buckets
16
+ - **Streaming** — Efficient file streaming
17
+
5
18
  ## Installation
6
19
 
7
20
  ```bash
@@ -12,15 +25,37 @@ npm install @zola_do/minio
12
25
  npm install @zola_do/nestjs-shared
13
26
  ```
14
27
 
15
- **Note:** If installation fails due to `nestjs-minio-client` postinstall script, use `npm install --ignore-scripts`.
28
+ **Note:** If installation fails due to `nestjs-minio-client` postinstall script, use:
29
+
30
+ ```bash
31
+ npm install @zola_do/minio --ignore-scripts
32
+ ```
33
+
34
+ ### Dependencies
16
35
 
17
- ## Usage
36
+ ```bash
37
+ npm install nestjs-minio-client
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ### 1. Configure Environment
18
43
 
19
- ### Module Setup
44
+ ```bash
45
+ # .env
46
+ MINIO_ENDPOINT=localhost
47
+ MINIO_PORT=9000
48
+ MINIO_USESSL=false
49
+ MINIO_ACCESSKEY=your-access-key
50
+ MINIO_SECRETKEY=your-secret-key
51
+ DURATION_OF_PRE_SIGNED_DOCUMENT=120
52
+ ```
53
+
54
+ ### 2. Register Module
20
55
 
21
56
  ```typescript
22
- import { Module } from '@nestjs/common';
23
- import { MinIoModule } from '@zola_do/minio';
57
+ import { Module } from "@nestjs/common";
58
+ import { MinIoModule } from "@zola_do/minio";
24
59
 
25
60
  @Module({
26
61
  imports: [MinIoModule],
@@ -28,80 +63,353 @@ import { MinIoModule } from '@zola_do/minio';
28
63
  export class AppModule {}
29
64
  ```
30
65
 
31
- ### Uploading Files
66
+ ### 3. Use Service
32
67
 
33
68
  ```typescript
34
- import { Injectable } from '@nestjs/common';
35
- import { MinIOService, BucketNameEnum } from '@zola_do/minio';
69
+ import { Injectable } from "@nestjs/common";
70
+ import { MinIOService, BucketNameEnum } from "@zola_do/minio";
36
71
 
37
72
  @Injectable()
38
- export class FileUploadService {
73
+ export class FileService {
39
74
  constructor(private readonly minioService: MinIOService) {}
40
75
 
41
- async uploadFile(file: Express.Multer.File, bucketName: string) {
42
- return await this.minioService.upload(file, bucketName);
43
- // Returns { filepath, bucketName, contentType, originalname }
76
+ async uploadFile(file: Express.Multer.File) {
77
+ return await this.minioService.upload(file, BucketNameEnum.MEGP);
44
78
  }
79
+ }
80
+ ```
81
+
82
+ ## MinIO Architecture
83
+
84
+ ```
85
+ ┌─────────────────────────────────────────────────────────────────────┐
86
+ │ MinIO Flow │
87
+ ├─────────────────────────────────────────────────────────────────────┤
88
+ │ │
89
+ │ ┌──────────┐ │
90
+ │ │ Client │ │
91
+ │ └────┬─────┘ │
92
+ │ │ │
93
+ │ │ 1. Request presigned URL │
94
+ │ ├─────────────────────────────────────┐ │
95
+ │ │ │ │
96
+ │ │ ┌───────────────┐ │ │
97
+ │ │ │ Controller │ │ │
98
+ │ │ └───────┬───────┘ │ │
99
+ │ │ │ │ │
100
+ │ │ │ 2. Generate URL │ │
101
+ │ │ ▼ │ │
102
+ │ │ ┌───────────────┐ │ │
103
+ │ │ │ MinIOService │ │ │
104
+ │ │ └───────┬───────┘ │ │
105
+ │ │ │ │ │
106
+ │ │ │ 3. Client PUT │ │
107
+ │ │<─────────┼──────────────────────────┘ │
108
+ │ │ │ │
109
+ │ │ ▼ │
110
+ │ │ ┌───────────────┐ │ │
111
+ │ │ │ MinIO │◄─────────────────┘ │
112
+ │ │ │ Server │ Direct upload │
113
+ │ │ └───────────────┘ │
114
+ │ │ │
115
+ │ │ 4. File stored │
116
+ │ │ ┌───────────────┐ │
117
+ │ │ │ Bucket │ │
118
+ │ │ │ documents/ │ │
119
+ │ │ └───────────────┘ │
120
+ │ │ │
121
+ └───────┴─────────────────────────────────────────────────────────────┘
122
+ ```
123
+
124
+ ## Upload Operations
125
+
126
+ ### File Upload
127
+
128
+ ```typescript
129
+ async uploadFile(file: Express.Multer.File) {
130
+ const result = await this.minioService.upload(
131
+ file,
132
+ BucketNameEnum.MEGP,
133
+ );
134
+ // Returns: { filepath, bucketName, contentType, originalname }
135
+ }
136
+ ```
137
+
138
+ ### Buffer Upload
139
+
140
+ ```typescript
141
+ async uploadBuffer(
142
+ buffer: Buffer,
143
+ filename: string,
144
+ mimetype: string,
145
+ ) {
146
+ const result = await this.minioService.uploadBuffer(
147
+ buffer,
148
+ filename,
149
+ mimetype,
150
+ BucketNameEnum.MEGP,
151
+ );
152
+ return result;
153
+ }
154
+ ```
155
+
156
+ ### Custom Bucket
157
+
158
+ ```typescript
159
+ async uploadToCustomBucket(file: Express.Multer.File, bucketName: string) {
160
+ // Ensure bucket exists
161
+ await this.minioService.ensureBucket(bucketName);
162
+
163
+ return await this.minioService.upload(file, bucketName);
164
+ }
165
+ ```
166
+
167
+ ## Download Operations
168
+
169
+ ### Download to Buffer
170
+
171
+ ```typescript
172
+ async downloadFile(filepath: string, bucketName: string): Promise<Buffer> {
173
+ const buffer = await this.minioService.downloadBuffer({
174
+ filepath,
175
+ bucketName,
176
+ });
177
+ return buffer;
178
+ }
179
+ ```
180
+
181
+ ### Download to Response
182
+
183
+ ```typescript
184
+ async downloadToResponse(
185
+ @Param('filepath') filepath: string,
186
+ @Res() res: Response,
187
+ ) {
188
+ const buffer = await this.minioService.downloadBuffer({
189
+ filepath: `documents/${filepath}`,
190
+ bucketName: BucketNameEnum.MEGP,
191
+ });
192
+
193
+ res.setHeader('Content-Type', 'application/pdf');
194
+ res.setHeader('Content-Disposition', `attachment; filename="${filepath}"`);
195
+ res.end(buffer);
196
+ }
197
+ ```
198
+
199
+ ## Presigned URLs
200
+
201
+ ### Generate Upload URL
202
+
203
+ ```typescript
204
+ async getUploadUrl(filename: string, contentType: string) {
205
+ const { presignedUrl, file } = await this.minioService.generatePresignedUploadUrl(
206
+ { originalname: filename, contentType },
207
+ 'documents/', // Folder prefix
208
+ );
209
+
210
+ return {
211
+ presignedUrl,
212
+ filepath: file.filepath,
213
+ bucketName: file.bucketName,
214
+ };
215
+ }
216
+ ```
217
+
218
+ ### Generate Download URL
219
+
220
+ ```typescript
221
+ async getDownloadUrl(filepath: string) {
222
+ const fileInfo = {
223
+ filepath,
224
+ bucketName: BucketNameEnum.MEGP,
225
+ contentType: 'application/pdf',
226
+ originalname: 'document.pdf',
227
+ };
228
+
229
+ const presignedUrl = await this.minioService.generatePresignedDownloadUrl(fileInfo);
230
+ return { downloadUrl: presignedUrl };
231
+ }
232
+ ```
233
+
234
+ ### Client-Side Upload Example
235
+
236
+ ```typescript
237
+ // Backend
238
+ @Post('upload-url')
239
+ async getUploadUrl() {
240
+ const { presignedUrl, file } = await this.minioService.generatePresignedUploadUrl(
241
+ { originalname: 'report.pdf', contentType: 'application/pdf' },
242
+ 'reports/',
243
+ );
244
+ return { presignedUrl, file };
245
+ }
246
+
247
+ // Frontend (React/Angular/Vue)
248
+ const response = await fetch('/api/upload-url');
249
+ const { presignedUrl, file } = await response.json();
250
+
251
+ await fetch(presignedUrl, {
252
+ method: 'PUT',
253
+ body: fileBuffer,
254
+ headers: { 'Content-Type': 'application/pdf' },
255
+ });
256
+ ```
257
+
258
+ ## BucketNameEnum
259
+
260
+ Predefined bucket names:
261
+
262
+ ```typescript
263
+ enum BucketNameEnum {
264
+ MEGP = "megp",
265
+ SPD_TEMPLATE = "spd_template",
266
+ // Add more buckets as needed
267
+ }
268
+ ```
269
+
270
+ ### Custom Buckets
271
+
272
+ ```typescript
273
+ // Define custom bucket names
274
+ const MY_BUCKETS = {
275
+ DOCUMENTS: "my-documents",
276
+ IMAGES: "my-images",
277
+ EXPORTS: "my-exports",
278
+ } as const;
279
+ ```
280
+
281
+ ### Ensure Bucket Exists
282
+
283
+ ```typescript
284
+ async ensureBucketExists(bucketName: string) {
285
+ await this.minioService.ensureBucket(bucketName);
286
+ }
287
+ ```
288
+
289
+ ## Environment Variables
290
+
291
+ | Variable | Description | Default |
292
+ | --------------------------------- | ------------------------------ | -------- |
293
+ | `MINIO_ENDPOINT` | MinIO server endpoint | Required |
294
+ | `MINIO_PORT` | MinIO port | `443` |
295
+ | `MINIO_USESSL` | Use SSL | `true` |
296
+ | `MINIO_ACCESSKEY` | MinIO access key | Required |
297
+ | `MINIO_SECRETKEY` | MinIO secret key | Required |
298
+ | `DURATION_OF_PRE_SIGNED_DOCUMENT` | Presigned URL expiry (seconds) | `120` |
299
+
300
+ ## PresignedFileUploadDto
301
+
302
+ Response type for presigned upload:
303
+
304
+ ```typescript
305
+ interface PresignedFileUploadDto {
306
+ presignedUrl: string;
307
+ file: {
308
+ filepath: string;
309
+ bucketName: string;
310
+ contentType: string;
311
+ originalname: string;
312
+ };
313
+ }
314
+ ```
315
+
316
+ ## API Reference
317
+
318
+ ### Module
319
+
320
+ ```typescript
321
+ MinIoModule.forRoot(options?: MinIoModuleOptions)
322
+ MinIoModule.forRootAsync(options?: MinIoModuleAsyncOptions)
323
+ ```
324
+
325
+ ### Service
326
+
327
+ ```typescript
328
+ class MinIOService {
329
+ async upload(
330
+ file: Express.Multer.File,
331
+ bucketName: string,
332
+ ): Promise<{
333
+ filepath: string;
334
+ bucketName: string;
335
+ contentType: string;
336
+ originalname: string;
337
+ }>;
45
338
 
46
339
  async uploadBuffer(
47
340
  buffer: Buffer,
48
341
  originalname: string,
49
342
  mimetype: string,
50
343
  bucketName: string,
51
- ) {
52
- return await this.minioService.uploadBuffer(
53
- buffer,
54
- originalname,
55
- mimetype,
56
- bucketName,
57
- );
58
- }
344
+ ): Promise<FileUploadResult>;
345
+
346
+ async downloadBuffer(fileInfo: FileInfo): Promise<Buffer>;
347
+
348
+ async generatePresignedUploadUrl(
349
+ file: Partial<FileInfo>,
350
+ folder?: string,
351
+ expiry?: number,
352
+ ): Promise<PresignedFileUploadDto>;
353
+
354
+ async generatePresignedDownloadUrl(
355
+ fileInfo: FileInfo,
356
+ expiry?: number,
357
+ ): Promise<string>;
358
+
359
+ async ensureBucket(bucketName: string): Promise<void>;
59
360
  }
60
361
  ```
61
362
 
62
- ### Presigned URLs
363
+ ## Troubleshooting
63
364
 
64
- Generate presigned upload URLs for client-side uploads:
365
+ ### Q: Connection refused error?
65
366
 
66
- ```typescript
67
- const { presignedUrl, file } = await this.minioService.generatePresignedUploadUrl(
68
- { originalname: 'document.pdf', contentType: 'application/pdf' },
69
- 'documents/',
70
- );
71
- // Send presignedUrl to client; they upload directly to MinIO
367
+ Verify MinIO is running:
368
+
369
+ ```bash
370
+ docker run -p 9000:9000 minio/minio server /data
72
371
  ```
73
372
 
74
- ### Downloading Files
373
+ ### Q: Bucket not found?
374
+
375
+ Create the bucket in MinIO console or use `ensureBucket()`:
75
376
 
76
377
  ```typescript
77
- const stream = await this.minioService.downloadBuffer({
78
- filepath: 'path/to/file.pdf',
79
- bucketName: BucketNameEnum.MEGP,
80
- });
378
+ await this.minioService.ensureBucket("my-bucket");
81
379
  ```
82
380
 
83
- ## Environment Variables
381
+ ### Q: Presigned URL expired?
84
382
 
85
- | Variable | Description |
86
- |----------|-------------|
87
- | `MINIO_ENDPOINT` | MinIO server endpoint |
88
- | `MINIO_PORT` | MinIO port (default: 443) |
89
- | `MINIO_USESSL` | Use SSL (default: true) |
90
- | `MINIO_ACCESSKEY` | MinIO access key |
91
- | `MINIO_SECRETKEY` | MinIO secret key |
92
- | `DURATION_OF_PRE_SIGNED_DOCUMENT` | Presigned URL expiry in seconds (default: 120) |
383
+ Increase `DURATION_OF_PRE_SIGNED_DOCUMENT` or pass custom expiry:
93
384
 
94
- ## Exports
385
+ ```typescript
386
+ await this.minioService.generatePresignedUploadUrl(file, "folder", 3600);
387
+ ```
95
388
 
96
- - `MinIoModule` Register the MinIO module
97
- - `MinIOService` — Upload, download, presigned URLs
98
- - `BucketNameEnum` — Bucket name constants
99
- - `PresignedFileUploadDto` — DTO for presigned upload responses
389
+ ### Q: File upload fails with CORS?
390
+
391
+ Configure MinIO CORS:
392
+
393
+ ```bash
394
+ mc cors set minio/ALIAS <<EOF
395
+ {
396
+ "CORSRules": [{
397
+ "AllowedOrigins": ["*"],
398
+ "AllowedMethods": ["GET", "PUT", "POST", "DELETE"],
399
+ "AllowedHeaders": ["*"]
400
+ }]
401
+ }
402
+ EOF
403
+ ```
100
404
 
101
405
  ## Related Packages
102
406
 
103
407
  - [@zola_do/document-manipulator](../document-manipulator) — Uses MinIO for document storage
104
408
 
409
+ ## License
410
+
411
+ ISC
412
+
105
413
  ## Community
106
414
 
107
415
  - [Contributing](../../CONTRIBUTING.md)
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
+ export * from './zola-object-storage';
1
2
  export * from './presigned-file-upload.dto';
2
3
  export * from './bucket-name.enum';
3
4
  export * from './min-io.module';
4
5
  export * from './min-io.service';
6
+ export * from './min-io.zola-object-storage';
package/dist/index.js CHANGED
@@ -14,8 +14,10 @@ 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);
17
18
  __exportStar(require("./presigned-file-upload.dto"), exports);
18
19
  __exportStar(require("./bucket-name.enum"), exports);
19
20
  __exportStar(require("./min-io.module"), exports);
20
21
  __exportStar(require("./min-io.service"), exports);
22
+ __exportStar(require("./min-io.zola-object-storage"), exports);
21
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,qDAAmC;AACnC,kDAAgC;AAChC,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,8DAA4C;AAC5C,qDAAmC;AACnC,kDAAgC;AAChC,mDAAiC;AACjC,+DAA6C"}
@@ -11,6 +11,7 @@ exports.MinIOModule = void 0;
11
11
  const common_1 = require("@nestjs/common");
12
12
  const nestjs_minio_client_1 = require("nestjs-minio-client");
13
13
  const min_io_service_1 = require("./min-io.service");
14
+ const min_io_zola_object_storage_1 = require("./min-io.zola-object-storage");
14
15
  let MinIOModule = class MinIOModule {
15
16
  };
16
17
  exports.MinIOModule = MinIOModule;
@@ -26,8 +27,8 @@ exports.MinIOModule = MinIOModule = __decorate([
26
27
  }),
27
28
  ],
28
29
  controllers: [],
29
- providers: [min_io_service_1.MinIOService],
30
- exports: [min_io_service_1.MinIOService],
30
+ providers: [min_io_service_1.MinIOService, min_io_zola_object_storage_1.MinioZolaObjectStorage],
31
+ exports: [min_io_service_1.MinIOService, min_io_zola_object_storage_1.MinioZolaObjectStorage],
31
32
  })
32
33
  ], MinIOModule);
33
34
  //# sourceMappingURL=min-io.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"min-io.module.js","sourceRoot":"","sources":["../src/min-io.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAwC;AACxC,6DAAkD;AAClD,qDAAgD;AAgBzC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAdvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,iCAAW,CAAC,QAAQ,CAAC;gBACnB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;gBACpC,IAAI,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,UAAU,mCAAI,GAAG,CAAC;gBAC3C,MAAM,EAAE,OAAO,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,YAAY,mCAAI,IAAI,CAAC;gBACjD,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;gBACtC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;aACvC,CAAC;SACH;QACD,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,CAAC,6BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,6BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"}
1
+ {"version":3,"file":"min-io.module.js","sourceRoot":"","sources":["../src/min-io.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAwC;AACxC,6DAAkD;AAClD,qDAAgD;AAChD,6EAAsE;AAgB/D,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAdvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,iCAAW,CAAC,QAAQ,CAAC;gBACnB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;gBACpC,IAAI,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,UAAU,mCAAI,GAAG,CAAC;gBAC3C,MAAM,EAAE,OAAO,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,YAAY,mCAAI,IAAI,CAAC;gBACjD,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;gBACtC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;aACvC,CAAC;SACH;QACD,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,CAAC,6BAAY,EAAE,mDAAsB,CAAC;QACjD,OAAO,EAAE,CAAC,6BAAY,EAAE,mDAAsB,CAAC;KAChD,CAAC;GACW,WAAW,CAAG"}
@@ -0,0 +1,16 @@
1
+ import { ZolaObjectStorage, ZolaStoredFileRef } from './zola-object-storage';
2
+ import { MinIOService } from './min-io.service';
3
+ export declare class MinioZolaObjectStorage implements ZolaObjectStorage {
4
+ private readonly minio;
5
+ constructor(minio: MinIOService);
6
+ uploadFile(file: Express.Multer.File, bucketName: string, metaData?: Record<string, string>): Promise<ZolaStoredFileRef>;
7
+ uploadBuffer(buffer: Buffer, originalname: string, mimetype: string, bucketName: string, metaData?: Record<string, string>): Promise<ZolaStoredFileRef>;
8
+ generatePresignedUploadUrl(fileInfo: {
9
+ originalname: string;
10
+ contentType?: string;
11
+ }, bucketName: string): Promise<{
12
+ presignedUrl: string;
13
+ file: ZolaStoredFileRef;
14
+ }>;
15
+ generatePresignedDownloadUrl(fileInfo: Pick<ZolaStoredFileRef, 'bucketName' | 'filepath' | 'contentType' | 'originalname'>): Promise<string>;
16
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MinioZolaObjectStorage = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const min_io_service_1 = require("./min-io.service");
15
+ let MinioZolaObjectStorage = class MinioZolaObjectStorage {
16
+ constructor(minio) {
17
+ this.minio = minio;
18
+ }
19
+ uploadFile(file, bucketName, metaData) {
20
+ return this.minio.upload(file, bucketName, metaData);
21
+ }
22
+ uploadBuffer(buffer, originalname, mimetype, bucketName, metaData) {
23
+ return this.minio.uploadBuffer(buffer, originalname, mimetype, bucketName, metaData);
24
+ }
25
+ async generatePresignedUploadUrl(fileInfo, bucketName) {
26
+ const result = await this.minio.generatePresignedUploadUrl(fileInfo, bucketName);
27
+ return {
28
+ presignedUrl: result.presignedUrl,
29
+ file: result.file,
30
+ };
31
+ }
32
+ async generatePresignedDownloadUrl(fileInfo) {
33
+ return this.minio.generatePresignedDownloadUrl(fileInfo);
34
+ }
35
+ };
36
+ exports.MinioZolaObjectStorage = MinioZolaObjectStorage;
37
+ exports.MinioZolaObjectStorage = MinioZolaObjectStorage = __decorate([
38
+ (0, common_1.Injectable)(),
39
+ __metadata("design:paramtypes", [min_io_service_1.MinIOService])
40
+ ], MinioZolaObjectStorage);
41
+ //# sourceMappingURL=min-io.zola-object-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"min-io.zola-object-storage.js","sourceRoot":"","sources":["../src/min-io.zola-object-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,qDAAgD;AAGzC,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YAA6B,KAAmB;QAAnB,UAAK,GAAL,KAAK,CAAc;IAAG,CAAC;IAEpD,UAAU,CACR,IAAyB,EACzB,UAAkB,EAClB,QAAiC;QAEjC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;IAED,YAAY,CACV,MAAc,EACd,YAAoB,EACpB,QAAgB,EAChB,UAAkB,EAClB,QAAiC;QAEjC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAC5B,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,0BAA0B,CAC9B,QAAwD,EACxD,UAAkB;QAElB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,0BAA0B,CACxD,QAAQ,EACR,UAAU,CACX,CAAC;QACF,OAAO;YACL,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,4BAA4B,CAChC,QAGC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AAjDY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAEyB,6BAAY;GADrC,sBAAsB,CAiDlC"}
@@ -0,0 +1,19 @@
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;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZOLA_STORAGE_CONTRACT_VERSION = void 0;
4
+ exports.ZOLA_STORAGE_CONTRACT_VERSION = 1;
5
+ //# sourceMappingURL=zola-object-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zola-object-storage.js","sourceRoot":"","sources":["../src/zola-object-storage.ts"],"names":[],"mappings":";;;AA2Ca,QAAA,6BAA6B,GAAG,CAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zola_do/minio",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "MinIO object storage for NestJS",
5
5
  "author": "zolaDO",
6
6
  "license": "ISC",