@builder6/files 0.10.8

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 ADDED
@@ -0,0 +1,21 @@
1
+ # Builder6 Email Module
2
+
3
+
4
+ ## Environment Variables
5
+
6
+ ```shell
7
+ B6_EMAIL_FROM=Steedos <noreply@steedos.com>
8
+ B6_EMAIL_HOST=email.xxxx.amazonaws.com
9
+ B6_EMAIL_PORT=465
10
+ B6_EMAIL_USERNAME=xxxxx
11
+ B6_EMAIL_PASSWORD=xxxxx
12
+ B6_EMAIL_SECURE=false
13
+ B6_EMAIL_DEBUG=true
14
+ B6_EMAIL_LOGGER=true
15
+ ```
16
+
17
+ ## 配置定时发送
18
+
19
+ ```
20
+ STEEDOS_CRON_MAILQUEUE_INTERVAL=3000 # 邮件定时器,单位:毫秒
21
+ ```
@@ -0,0 +1,12 @@
1
+ /// <reference types="multer" />
2
+ import { FilesService } from './files.service';
3
+ import { Response } from 'express';
4
+ export declare class FilesController {
5
+ private readonly filesService;
6
+ constructor(filesService: FilesService);
7
+ uploadFile(collectionName: string, file: Express.Multer.File, object_name: string, record_id: string, parent: string, req: Request): Promise<object>;
8
+ downloadFile(collectionName: string, fileId: string, fileName: string, res: Response): Promise<void>;
9
+ presignedUrls(collectionName: string, records: string[]): Promise<{
10
+ urls: string[];
11
+ }>;
12
+ }
@@ -0,0 +1,171 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FilesController = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const platform_express_1 = require("@nestjs/platform-express");
18
+ const files_service_1 = require("./files.service");
19
+ const swagger_1 = require("@nestjs/swagger");
20
+ const core_1 = require("@builder6/core");
21
+ let FilesController = class FilesController {
22
+ constructor(filesService) {
23
+ this.filesService = filesService;
24
+ }
25
+ async uploadFile(collectionName, file, object_name, record_id, parent, req) {
26
+ const user = req['user'];
27
+ if (!file) {
28
+ throw new Error('未找到上传的文件');
29
+ }
30
+ const fileRecord = await this.filesService.uploadFile(collectionName, file, { object_name, record_id, parent, owner: user._id, space: user.space });
31
+ return fileRecord;
32
+ }
33
+ async downloadFile(collectionName, fileId, fileName, res) {
34
+ try {
35
+ if (this.filesService.cfsStore === 'S3') {
36
+ const s3SignedUrl = await this.filesService.getPreSignedUrl(collectionName, fileId);
37
+ if (s3SignedUrl) {
38
+ return res.redirect(s3SignedUrl);
39
+ }
40
+ }
41
+ const fileStream = await this.filesService.downloadFileStream(collectionName, fileId);
42
+ fileStream.pipe(res).on('error', () => {
43
+ throw new common_1.HttpException('文件下载失败', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
44
+ });
45
+ }
46
+ catch (error) {
47
+ throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
48
+ }
49
+ }
50
+ async presignedUrls(collectionName, records) {
51
+ const urls = await Promise.all(records.map(async (attachmentId) => {
52
+ return this.filesService.getPreSignedUrl(collectionName, attachmentId);
53
+ }));
54
+ return { urls };
55
+ }
56
+ };
57
+ __decorate([
58
+ (0, common_1.Post)(':collectionName'),
59
+ (0, common_1.HttpCode)(200),
60
+ (0, swagger_1.ApiOperation)({ summary: 'Upload a file' }),
61
+ (0, swagger_1.ApiParam)({
62
+ name: 'collectionName',
63
+ required: true,
64
+ type: 'string',
65
+ schema: {
66
+ type: 'string',
67
+ default: 'cfs.files.filerecord',
68
+ },
69
+ }),
70
+ (0, swagger_1.ApiConsumes)('multipart/form-data'),
71
+ (0, swagger_1.ApiBody)({
72
+ schema: {
73
+ type: 'object',
74
+ properties: {
75
+ file: {
76
+ type: 'string',
77
+ format: 'binary',
78
+ },
79
+ object_name: {
80
+ type: 'string',
81
+ description: 'Object Name',
82
+ default: '',
83
+ },
84
+ record_id: {
85
+ type: 'string',
86
+ description: 'Record id',
87
+ default: '',
88
+ },
89
+ parent: {
90
+ type: 'string',
91
+ description: 'Parent record id',
92
+ default: '',
93
+ },
94
+ },
95
+ },
96
+ }),
97
+ (0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file')),
98
+ __param(0, (0, common_1.Param)('collectionName')),
99
+ __param(1, (0, common_1.UploadedFile)()),
100
+ __param(2, (0, common_1.Body)('object_name')),
101
+ __param(3, (0, common_1.Body)('record_id')),
102
+ __param(4, (0, common_1.Body)('parent')),
103
+ __param(5, (0, common_1.Req)()),
104
+ __metadata("design:type", Function),
105
+ __metadata("design:paramtypes", [String, Object, String, String, String, Request]),
106
+ __metadata("design:returntype", Promise)
107
+ ], FilesController.prototype, "uploadFile", null);
108
+ __decorate([
109
+ (0, common_1.Get)(':collectionName/:fileId/:fileName?'),
110
+ (0, swagger_1.ApiOperation)({ summary: 'Download a file' }),
111
+ (0, swagger_1.ApiParam)({
112
+ name: 'collectionName',
113
+ required: true,
114
+ type: 'string',
115
+ schema: {
116
+ type: 'string',
117
+ default: 'cfs.files.filerecord',
118
+ },
119
+ }),
120
+ (0, swagger_1.ApiParam)({
121
+ name: 'fileName',
122
+ required: false,
123
+ type: 'string',
124
+ }),
125
+ __param(0, (0, common_1.Param)('collectionName')),
126
+ __param(1, (0, common_1.Param)('fileId')),
127
+ __param(2, (0, common_1.Param)('fileName')),
128
+ __param(3, (0, common_1.Res)()),
129
+ __metadata("design:type", Function),
130
+ __metadata("design:paramtypes", [String, String, String, Object]),
131
+ __metadata("design:returntype", Promise)
132
+ ], FilesController.prototype, "downloadFile", null);
133
+ __decorate([
134
+ (0, common_1.Post)(':collectionName/presigned-urls'),
135
+ (0, swagger_1.ApiOperation)({ summary: 'Get presigned urls for files' }),
136
+ (0, swagger_1.ApiBody)({
137
+ schema: {
138
+ type: 'object',
139
+ description: 'Array of record id',
140
+ properties: {
141
+ records: {
142
+ type: 'array',
143
+ items: {
144
+ type: 'string',
145
+ },
146
+ },
147
+ },
148
+ },
149
+ }),
150
+ (0, swagger_1.ApiParam)({
151
+ name: 'collectionName',
152
+ required: true,
153
+ type: 'string',
154
+ schema: {
155
+ type: 'string',
156
+ default: 'cfs.files.filerecord',
157
+ },
158
+ }),
159
+ __param(0, (0, common_1.Param)('collectionName')),
160
+ __param(1, (0, common_1.Body)('records')),
161
+ __metadata("design:type", Function),
162
+ __metadata("design:paramtypes", [String, Array]),
163
+ __metadata("design:returntype", Promise)
164
+ ], FilesController.prototype, "presignedUrls", null);
165
+ FilesController = __decorate([
166
+ (0, common_1.Controller)('api/v6/files/'),
167
+ (0, common_1.UseGuards)(core_1.AuthGuard),
168
+ __metadata("design:paramtypes", [files_service_1.FilesService])
169
+ ], FilesController);
170
+ exports.FilesController = FilesController;
171
+ //# sourceMappingURL=files.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.controller.js","sourceRoot":"","sources":["../../src/files/files.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAcwB;AACxB,+DAA2D;AAC3D,mDAA+C;AAE/C,6CAA+E;AAC/E,yCAA2C;AAIpC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IA0CrD,AAAN,KAAK,CAAC,UAAU,CACW,cAAsB,EAC/B,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AA,kBAAQ,EAAC;QACR,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,sBAAsB;SAChC;KACF,CAAC;IAEC,WAAA,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAA;IACvB,WAAA,IAAA,aAAI,EAAC,SAAS,CAAC,CAAA;;;;oDAQjB;AAvJU,eAAe;IAF3B,IAAA,mBAAU,EAAC,eAAe,CAAC;IAC3B,IAAA,kBAAS,EAAC,gBAAS,CAAC;qCAEwB,4BAAY;GAD5C,eAAe,CAwJ3B;AAxJY,0CAAe"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const testing_1 = require("@nestjs/testing");
4
+ const files_controller_1 = require("./files.controller");
5
+ describe('FilesController', () => {
6
+ let controller;
7
+ beforeEach(async () => {
8
+ const module = await testing_1.Test.createTestingModule({
9
+ controllers: [files_controller_1.FilesController],
10
+ }).compile();
11
+ controller = module.get(files_controller_1.FilesController);
12
+ });
13
+ it('should be defined', () => {
14
+ expect(controller).toBeDefined();
15
+ });
16
+ });
17
+ //# sourceMappingURL=files.controller.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.controller.spec.js","sourceRoot":"","sources":["../../src/files/files.controller.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,yDAAqD;AAErD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,UAA2B,CAAC;IAEhC,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,WAAW,EAAE,CAAC,kCAAe,CAAC;SAC/B,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,UAAU,GAAG,MAAM,CAAC,GAAG,CAAkB,kCAAe,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare class FilesModule {
2
+ }
@@ -0,0 +1,27 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.FilesModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const files_controller_1 = require("./files.controller");
12
+ const files_service_1 = require("./files.service");
13
+ const core_1 = require("@builder6/core");
14
+ const files_moleculer_1 = require("./files.moleculer");
15
+ const core_2 = require("@builder6/core");
16
+ let FilesModule = class FilesModule {
17
+ };
18
+ FilesModule = __decorate([
19
+ (0, common_1.Module)({
20
+ imports: [core_2.AuthModule, core_1.MongodbModule],
21
+ controllers: [files_controller_1.FilesController],
22
+ providers: [files_service_1.FilesService, files_moleculer_1.FilesMoleculer],
23
+ exports: [files_service_1.FilesService],
24
+ })
25
+ ], FilesModule);
26
+ exports.FilesModule = FilesModule;
27
+ //# sourceMappingURL=files.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.module.js","sourceRoot":"","sources":["../../src/files/files.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yDAAqD;AACrD,mDAA+C;AAC/C,yCAA+C;AAC/C,uDAAmD;AACnD,yCAA4C;AAQrC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IANvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,iBAAU,EAAE,oBAAa,CAAC;QACpC,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,4BAAY,EAAE,gCAAc,CAAC;QACzC,OAAO,EAAE,CAAC,4BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG;AAAd,kCAAW"}
@@ -0,0 +1,10 @@
1
+ import { Service, Context, ServiceBroker } from 'moleculer';
2
+ import { FilesService } from './files.service';
3
+ export declare class FilesMoleculer extends Service {
4
+ private filesService;
5
+ constructor(filesService: FilesService, broker: ServiceBroker);
6
+ serviceCreated(): void;
7
+ serviceStarted(): Promise<void>;
8
+ serviceStopped(): Promise<void>;
9
+ getPreSignedUrl(ctx: Context): Promise<string>;
10
+ }
@@ -0,0 +1,50 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FilesMoleculer = void 0;
16
+ const moleculer_1 = require("moleculer");
17
+ const common_1 = require("@nestjs/common");
18
+ const moleculer_2 = require("@builder6/moleculer");
19
+ const files_service_1 = require("./files.service");
20
+ let FilesMoleculer = class FilesMoleculer extends moleculer_1.Service {
21
+ constructor(filesService, broker) {
22
+ super(broker);
23
+ this.filesService = filesService;
24
+ this.parseServiceSchema({
25
+ name: '@builder6/files',
26
+ settings: {},
27
+ actions: {
28
+ getPreSignedUrl: this.getPreSignedUrl,
29
+ },
30
+ created: this.serviceCreated,
31
+ started: this.serviceStarted,
32
+ stopped: this.serviceStopped,
33
+ });
34
+ }
35
+ serviceCreated() { }
36
+ async serviceStarted() { }
37
+ async serviceStopped() { }
38
+ async getPreSignedUrl(ctx) {
39
+ const { collectionName, fileId } = ctx.params;
40
+ return this.filesService.getPreSignedUrl(collectionName, fileId);
41
+ }
42
+ };
43
+ FilesMoleculer = __decorate([
44
+ (0, common_1.Injectable)(),
45
+ __param(1, (0, moleculer_2.InjectBroker)()),
46
+ __metadata("design:paramtypes", [files_service_1.FilesService,
47
+ moleculer_1.ServiceBroker])
48
+ ], FilesMoleculer);
49
+ exports.FilesMoleculer = FilesMoleculer;
50
+ //# sourceMappingURL=files.moleculer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.moleculer.js","sourceRoot":"","sources":["../../src/files/files.moleculer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA4D;AAC5D,2CAAoD;AACpD,mDAAmD;AACnD,mDAA+C;AAGxC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,mBAAO;IACzC,YACU,YAA0B,EAClB,MAAqB;QAErC,KAAK,CAAC,MAAM,CAAC,CAAC;QAHN,iBAAY,GAAZ,YAAY,CAAc;QAKlC,IAAI,CAAC,kBAAkB,CAAC;YACtB,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE;gBACP,eAAe,EAAE,IAAI,CAAC,eAAe;aACtC;YACD,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,OAAO,EAAE,IAAI,CAAC,cAAc;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,cAAc,KAAI,CAAC;IAEnB,KAAK,CAAC,cAAc,KAAI,CAAC;IAEzB,KAAK,CAAC,cAAc,KAAI,CAAC;IAEzB,KAAK,CAAC,eAAe,CAAC,GAAY;QAChC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAa,CAAC;QAErD,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AA9BY,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAIR,WAAA,IAAA,wBAAY,GAAE,CAAA;qCADO,4BAAY;QACV,yBAAa;GAH5B,cAAc,CA8B1B;AA9BY,wCAAc"}
@@ -0,0 +1,34 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { MongodbService } from '@builder6/core';
5
+ import stream from 'stream';
6
+ import { ConfigService } from '@nestjs/config';
7
+ export declare class FilesService {
8
+ private configService;
9
+ private mongodbService;
10
+ private s3;
11
+ cfsStore: string;
12
+ storageDir: string;
13
+ s3Bucket: string;
14
+ rootUrl: string;
15
+ private readonly logger;
16
+ constructor(configService: ConfigService, mongodbService: MongodbService);
17
+ getCollectionFolderName(collectionName: any): string;
18
+ uploadFile(collectionName: string, file: {
19
+ buffer: Buffer;
20
+ originalname: string;
21
+ size: number;
22
+ mimetype?: string;
23
+ }, metadata: {
24
+ _id?: string;
25
+ owner?: string;
26
+ space?: string;
27
+ object_name?: string;
28
+ record_id?: string;
29
+ parent?: string;
30
+ }): Promise<object>;
31
+ getFile(collectionName: string, fileId: string): Promise<any>;
32
+ getPreSignedUrl(collectionName: string, fileId: string): Promise<string | null>;
33
+ downloadFileStream(collectionName: string, fileId: string): Promise<stream.Readable>;
34
+ }
@@ -0,0 +1,211 @@
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 FilesService_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.FilesService = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const AWS = require("aws-sdk");
16
+ const fs = require("fs-extra");
17
+ const uuid_1 = require("uuid");
18
+ const path = require("path");
19
+ const core_1 = require("@builder6/core");
20
+ const mime = require("mime-types");
21
+ const config_1 = require("@nestjs/config");
22
+ const crypto = require("crypto");
23
+ let FilesService = FilesService_1 = class FilesService {
24
+ constructor(configService, mongodbService) {
25
+ this.configService = configService;
26
+ this.mongodbService = mongodbService;
27
+ this.logger = new common_1.Logger(FilesService_1.name);
28
+ this.rootUrl = configService.get('host');
29
+ this.storageDir = configService.get('storage.dir') || './steedos-storage';
30
+ this.cfsStore = configService.get('cfs.store') || 'local';
31
+ if (this.cfsStore === 'S3') {
32
+ this.s3 = new AWS.S3({
33
+ endpoint: configService.get('cfs.aws.s3.endpoint'),
34
+ accessKeyId: configService.get('cfs.aws.s3.access.key.id'),
35
+ secretAccessKey: configService.get('cfs.aws.s3.secret.access.key'),
36
+ region: configService.get('cfs.aws.s3.region'),
37
+ signatureVersion: 'v4',
38
+ s3ForcePathStyle: configService.get('cfs.aws.s3.force.path.style'),
39
+ });
40
+ this.s3Bucket = configService.get('cfs.aws.s3.bucket');
41
+ }
42
+ }
43
+ getCollectionFolderName(collectionName) {
44
+ let collectionFolderName = collectionName;
45
+ const collectionNameParts = collectionName.split('.');
46
+ if (collectionNameParts.length === 3 &&
47
+ collectionNameParts[0] === 'cfs' &&
48
+ collectionNameParts[2] === 'filerecord') {
49
+ collectionFolderName = collectionNameParts[1];
50
+ }
51
+ return collectionFolderName;
52
+ }
53
+ async uploadFile(collectionName = 'cfs.files.filerecord', file, metadata) {
54
+ const { _id = (0, uuid_1.v4)(), object_name, owner, space, record_id, parent, } = metadata;
55
+ const fileName = Buffer.from(file.originalname, 'binary').toString('utf8');
56
+ const mimeType = file.mimetype || mime.lookup(fileName) || 'application/octet-stream';
57
+ let relativeKey;
58
+ const md5 = crypto.createHash('md5').update(file.buffer).digest('hex');
59
+ const currentDate = new Date();
60
+ const year = currentDate.getFullYear();
61
+ const month = (currentDate.getMonth() + 1).toString().padStart(2, '0');
62
+ const uniqueFileName = `${_id}-${fileName}`;
63
+ const collectionFolderName = this.getCollectionFolderName(collectionName);
64
+ if (this.cfsStore === 'local') {
65
+ const fileDir = path.join(this.storageDir, 'files', collectionFolderName, object_name || 'default', year.toString(), month);
66
+ relativeKey = path.join(object_name || 'default', year.toString(), month, uniqueFileName);
67
+ const filePath = path.join(fileDir, uniqueFileName);
68
+ try {
69
+ await fs.ensureDir(fileDir);
70
+ await fs.writeFile(filePath, file.buffer);
71
+ this.logger.log(`文件上传成功: ${filePath}`);
72
+ }
73
+ catch (err) {
74
+ throw new Error(`文件保存到本地失败: ${err.message}`);
75
+ }
76
+ }
77
+ else if (this.cfsStore === 'S3') {
78
+ relativeKey = `${collectionFolderName}/${object_name || 'default'}/${year}/${month}/${uniqueFileName}`;
79
+ const params = {
80
+ Bucket: this.s3Bucket,
81
+ Key: relativeKey,
82
+ Body: file.buffer,
83
+ ContentType: mimeType,
84
+ };
85
+ try {
86
+ const data = await this.s3.upload(params).promise();
87
+ this.logger.log(`文件上传S3成功: ${relativeKey}`);
88
+ }
89
+ catch (err) {
90
+ throw new Error(`文件上传失败: ${err.message}`);
91
+ }
92
+ }
93
+ else {
94
+ throw new Error('未知的文件存储类型');
95
+ }
96
+ const savedRecord = await this.mongodbService.insertOne(collectionName, {
97
+ _id,
98
+ original: {
99
+ type: mimeType,
100
+ size: file.size,
101
+ name: fileName,
102
+ md5,
103
+ },
104
+ metadata: {
105
+ owner: owner,
106
+ space: space,
107
+ record_id: record_id,
108
+ object_name: object_name,
109
+ parent: parent,
110
+ },
111
+ uploadedAt: new Date(),
112
+ copies: {
113
+ [collectionFolderName]: {
114
+ name: fileName,
115
+ type: mimeType,
116
+ size: file.size,
117
+ key: relativeKey,
118
+ updatedAt: new Date(),
119
+ createdAt: new Date(),
120
+ },
121
+ },
122
+ });
123
+ return savedRecord;
124
+ }
125
+ async getFile(collectionName, fileId) {
126
+ const fileRecord = await this.mongodbService.findOne(collectionName, {
127
+ _id: fileId,
128
+ });
129
+ return fileRecord;
130
+ }
131
+ async getPreSignedUrl(collectionName, fileId) {
132
+ const collectionFolderName = this.getCollectionFolderName(collectionName);
133
+ const fileRecord = await this.mongodbService.findOne(collectionName, {
134
+ _id: fileId,
135
+ });
136
+ if (!fileRecord) {
137
+ throw new Error('未找到指定的文件记录');
138
+ }
139
+ if (this.cfsStore === 'S3') {
140
+ const key = fileRecord.copies[collectionFolderName].key;
141
+ const params = {
142
+ Bucket: this.s3Bucket,
143
+ Key: key,
144
+ Expires: 60 * 60,
145
+ };
146
+ try {
147
+ return this.s3.getSignedUrl('getObject', params);
148
+ }
149
+ catch (err) {
150
+ throw new Error(`生成 S3 签名 URL 失败: ${err.message}`);
151
+ }
152
+ }
153
+ else if (this.cfsStore === 'local') {
154
+ return (this.rootUrl +
155
+ '/api/v6/files/' +
156
+ collectionName +
157
+ '/' +
158
+ fileId +
159
+ '/' +
160
+ fileRecord.original.name);
161
+ }
162
+ return null;
163
+ }
164
+ async downloadFileStream(collectionName, fileId) {
165
+ const fileRecord = await this.mongodbService.findOne(collectionName, {
166
+ _id: fileId,
167
+ });
168
+ const collectionFolderName = this.getCollectionFolderName(collectionName);
169
+ if (!fileRecord) {
170
+ throw new Error('未找到指定的文件记录');
171
+ }
172
+ if (this.cfsStore === 'local') {
173
+ try {
174
+ const key = fileRecord.copies[collectionFolderName].key;
175
+ const fileUrl = path.join(this.storageDir, 'files', collectionFolderName, key);
176
+ if (!(await fs.pathExists(fileUrl))) {
177
+ throw new Error('文件不存在');
178
+ }
179
+ return fs.createReadStream(fileUrl);
180
+ }
181
+ catch (err) {
182
+ throw new Error(`文件下载失败: ${err.message}`);
183
+ }
184
+ }
185
+ else if (this.cfsStore === 'S3') {
186
+ const key = fileRecord.copies[collectionFolderName].key;
187
+ const params = {
188
+ Bucket: this.s3Bucket,
189
+ Key: key,
190
+ Expires: 60 * 60,
191
+ };
192
+ try {
193
+ const s3Object = this.s3.getObject(params);
194
+ return s3Object.createReadStream();
195
+ }
196
+ catch (err) {
197
+ throw new Error(`文件下载失败: ${err.message}`);
198
+ }
199
+ }
200
+ else {
201
+ throw new Error('未知的文件存储类型');
202
+ }
203
+ }
204
+ };
205
+ FilesService = FilesService_1 = __decorate([
206
+ (0, common_1.Injectable)(),
207
+ __metadata("design:paramtypes", [config_1.ConfigService,
208
+ core_1.MongodbService])
209
+ ], FilesService);
210
+ exports.FilesService = FilesService;
211
+ //# sourceMappingURL=files.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.service.js","sourceRoot":"","sources":["../../src/files/files.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,+BAA+B;AAC/B,+BAA+B;AAC/B,+BAAkC;AAClC,6BAA6B;AAC7B,yCAAgD;AAEhD,mCAAmC;AACnC,2CAA+C;AAC/C,iCAAiC;AAG1B,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAQvB,YACU,aAA4B,EAC5B,cAA8B;QAD9B,kBAAa,GAAb,aAAa,CAAe;QAC5B,mBAAc,GAAd,cAAc,CAAgB;QAJvB,WAAM,GA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I,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE;oBACnC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;iBAC1B;gBAED,OAAO,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;aACrC;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;aAC3C;SACF;aAAM,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE;YACjC,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC;YAExD,MAAM,MAAM,GAAG;gBACb,MAAM,EAAE,IAAI,CAAC,QAAQ;gBACrB,GAAG,EAAE,GAAG;gBACR,OAAO,EAAE,EAAE,GAAG,EAAE;aACjB,CAAC;YAEF,IAAI;gBAEF,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBAC3C,OAAO,QAAQ,CAAC,gBAAgB,EAAE,CAAC;aACpC;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;aAC3C;SACF;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;SAC9B;IACH,CAAC;CACF,CAAA;AA9QY,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAUc,sBAAa;QACZ,qBAAc;GAV7B,YAAY,CA8QxB;AA9QY,oCAAY"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const testing_1 = require("@nestjs/testing");
4
+ const files_service_1 = require("./files.service");
5
+ describe('FilesService', () => {
6
+ let service;
7
+ beforeEach(async () => {
8
+ const module = await testing_1.Test.createTestingModule({
9
+ providers: [files_service_1.FilesService],
10
+ }).compile();
11
+ service = module.get(files_service_1.FilesService);
12
+ });
13
+ it('should be defined', () => {
14
+ expect(service).toBeDefined();
15
+ });
16
+ });
17
+ //# sourceMappingURL=files.service.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.service.spec.js","sourceRoot":"","sources":["../../src/files/files.service.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,mDAA+C;AAE/C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,OAAqB,CAAC;IAE1B,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE,CAAC,4BAAY,CAAC;SAC1B,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,OAAO,GAAG,MAAM,CAAC,GAAG,CAAe,4BAAY,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './files.controller';
2
+ export * from './files.module';
3
+ export * from './files.service';
4
+ export * from './files.moleculer';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./files.controller"), exports);
18
+ __exportStar(require("./files.module"), exports);
19
+ __exportStar(require("./files.service"), exports);
20
+ __exportStar(require("./files.moleculer"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,iDAA+B;AAC/B,kDAAgC;AAChC,oDAAkC"}
@@ -0,0 +1 @@
1
+ export * from './files';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./files"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@builder6/files",
3
+ "version": "0.10.8",
4
+ "main": "dist/index.js",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "scripts": {
10
+ "format": "prettier --write \"src/**/*.ts\"",
11
+ "build": "rimraf dist && tsc",
12
+ "build:watch": "rimraf dist && tsc --watch"
13
+ },
14
+ "dependencies": {
15
+ "@builder6/core": "^0.10.8",
16
+ "nodemailer": "^6.9.16"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "gitHead": "f0c0a42e68e5c70a3f1f3407b4c7b903ec21425e"
22
+ }