@nest-omni/core 1.0.57 → 2.0.1-1

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.
@@ -1,10 +0,0 @@
1
- import type { IFile } from '../../interfaces';
2
- import { ApiConfigService } from './api-config.service';
3
- import { GeneratorService } from './generator.service';
4
- export declare class AwsS3Service {
5
- configService: ApiConfigService;
6
- generatorService: GeneratorService;
7
- private readonly s3;
8
- constructor(configService: ApiConfigService, generatorService: GeneratorService);
9
- uploadImage(file: IFile): Promise<string>;
10
- }
@@ -1,56 +0,0 @@
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
- return new (P || (P = Promise))(function (resolve, reject) {
14
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
- step((generator = generator.apply(thisArg, _arguments || [])).next());
18
- });
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.AwsS3Service = void 0;
22
- const client_s3_1 = require("@aws-sdk/client-s3");
23
- const common_1 = require("@nestjs/common");
24
- const mime_types_1 = require("mime-types");
25
- const api_config_service_1 = require("./api-config.service");
26
- const generator_service_1 = require("./generator.service");
27
- let AwsS3Service = class AwsS3Service {
28
- constructor(configService, generatorService) {
29
- this.configService = configService;
30
- this.generatorService = generatorService;
31
- const awsS3Config = configService.awsS3Config;
32
- this.s3 = new client_s3_1.S3({
33
- apiVersion: awsS3Config.bucketApiVersion,
34
- region: awsS3Config.bucketRegion,
35
- });
36
- }
37
- uploadImage(file) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const fileName = this.generatorService.fileName(mime_types_1.default.extension(file.mimetype));
40
- const key = 'images/' + fileName;
41
- yield this.s3.putObject({
42
- Bucket: this.configService.awsS3Config.bucketName,
43
- Body: file.buffer,
44
- ACL: 'public-read',
45
- Key: key,
46
- });
47
- return key;
48
- });
49
- }
50
- };
51
- exports.AwsS3Service = AwsS3Service;
52
- exports.AwsS3Service = AwsS3Service = __decorate([
53
- (0, common_1.Injectable)(),
54
- __metadata("design:paramtypes", [api_config_service_1.ApiConfigService,
55
- generator_service_1.GeneratorService])
56
- ], AwsS3Service);