@builder6/core 0.6.5 → 0.7.0

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.
@@ -0,0 +1,11 @@
1
+ import { FilesService } from './files.service';
2
+ import { Response } from 'express';
3
+ export declare class FilesController {
4
+ private readonly filesService;
5
+ constructor(filesService: FilesService);
6
+ uploadFile(collectionName: string, file: Express.Multer.File, object_name: string, record_id: string, parent: string, req: Request): Promise<object>;
7
+ downloadFile(collectionName: string, fileId: string, fileName: string, res: Response): Promise<void>;
8
+ presignedUrls(collectionName: string, records: string[]): Promise<{
9
+ urls: string[];
10
+ }>;
11
+ }
@@ -0,0 +1,170 @@
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 auth_guard_1 = require("../auth/auth.guard");
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
+ exports.FilesController = FilesController;
58
+ __decorate([
59
+ (0, common_1.Post)(':collectionName'),
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
+ exports.FilesController = FilesController = __decorate([
166
+ (0, common_1.Controller)('api/v6/files/'),
167
+ (0, common_1.UseGuards)(auth_guard_1.AuthGuard),
168
+ __metadata("design:paramtypes", [files_service_1.FilesService])
169
+ ], FilesController);
170
+ //# 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,2CAawB;AACxB,+DAA2D;AAC3D,mDAA+C;AAE/C,6CAA+E;AAC/E,mDAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAyCrD,AAAN,KAAK,CAAC,UAAU,CACW,cAAsB,EAC/B,IAAyB,EACpB,WAAmB,EACrB,SAAiB,EACpB,MAAc,EACvB,GAAY;QAGnB,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CACnD,cAAc,EACd,IAAI,EACJ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CACvE,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,C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"}
@@ -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 mongodb_module_1 = require("../mongodb/mongodb.module");
14
+ const files_moleculer_1 = require("./files.moleculer");
15
+ const auth_module_1 = require("../auth/auth.module");
16
+ let FilesModule = class FilesModule {
17
+ };
18
+ exports.FilesModule = FilesModule;
19
+ exports.FilesModule = FilesModule = __decorate([
20
+ (0, common_1.Module)({
21
+ imports: [auth_module_1.AuthModule, mongodb_module_1.MongodbModule],
22
+ controllers: [files_controller_1.FilesController],
23
+ providers: [files_service_1.FilesService, files_moleculer_1.FilesMoleculer],
24
+ exports: [files_service_1.FilesService],
25
+ })
26
+ ], 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,8DAA0D;AAC1D,uDAAmD;AACnD,qDAAiD;AAQ1C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IANvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,wBAAU,EAAE,8BAAa,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"}
@@ -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
+ exports.FilesMoleculer = FilesMoleculer;
44
+ exports.FilesMoleculer = FilesMoleculer = __decorate([
45
+ (0, common_1.Injectable)(),
46
+ __param(1, (0, moleculer_2.InjectBroker)()),
47
+ __metadata("design:paramtypes", [files_service_1.FilesService,
48
+ moleculer_1.ServiceBroker])
49
+ ], 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,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAIR,WAAA,IAAA,wBAAY,GAAE,CAAA;qCADO,4BAAY;QACV,yBAAa;GAH5B,cAAc,CA8B1B"}
@@ -0,0 +1,31 @@
1
+ import { MongodbService } from '../mongodb/mongodb.service';
2
+ import stream from 'stream';
3
+ import { ConfigService } from '@nestjs/config';
4
+ export declare class FilesService {
5
+ private configService;
6
+ private mongodbService;
7
+ private s3;
8
+ cfsStore: string;
9
+ storageDir: string;
10
+ s3Bucket: string;
11
+ rootUrl: string;
12
+ private readonly logger;
13
+ constructor(configService: ConfigService, mongodbService: MongodbService);
14
+ getCollectionFolderName(collectionName: any): string;
15
+ uploadFile(collectionName: string, file: {
16
+ buffer: Buffer;
17
+ originalname: string;
18
+ size: number;
19
+ mimetype?: string;
20
+ }, metadata: {
21
+ _id?: string;
22
+ owner?: string;
23
+ space?: string;
24
+ object_name?: string;
25
+ record_id?: string;
26
+ parent?: string;
27
+ }): Promise<object>;
28
+ getFile(collectionName: string, fileId: string): Promise<any>;
29
+ getPreSignedUrl(collectionName: string, fileId: string): Promise<string | null>;
30
+ downloadFileStream(collectionName: string, fileId: string): Promise<stream.Readable>;
31
+ }
@@ -0,0 +1,210 @@
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 mongodb_service_1 = require("../mongodb/mongodb.service");
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('root.url');
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
+ });
39
+ this.s3Bucket = configService.get('cfs.aws.s3.bucket');
40
+ }
41
+ }
42
+ getCollectionFolderName(collectionName) {
43
+ let collectionFolderName = collectionName;
44
+ const collectionNameParts = collectionName.split('.');
45
+ if (collectionNameParts.length === 3 &&
46
+ collectionNameParts[0] === 'cfs' &&
47
+ collectionNameParts[2] === 'filerecord') {
48
+ collectionFolderName = collectionNameParts[1];
49
+ }
50
+ return collectionFolderName;
51
+ }
52
+ async uploadFile(collectionName = 'cfs.files.filerecord', file, metadata) {
53
+ const { _id = (0, uuid_1.v4)(), object_name, owner, space, record_id, parent, } = metadata;
54
+ const mimeType = file.mimetype ||
55
+ mime.lookup(file.originalname) ||
56
+ '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}-${file.originalname}`;
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
+ const collectionFolderName = this.getCollectionFolderName(collectionName);
79
+ relativeKey = `${collectionFolderName}/${object_name || 'default'}/${year}/${month}/${uniqueFileName}`;
80
+ const params = {
81
+ Bucket: this.s3Bucket,
82
+ Key: relativeKey,
83
+ Body: file.buffer,
84
+ ContentType: mimeType,
85
+ };
86
+ try {
87
+ const data = await this.s3.upload(params).promise();
88
+ this.logger.log(`文件上传S3成功: ${relativeKey}`);
89
+ }
90
+ catch (err) {
91
+ throw new Error(`文件上传失败: ${err.message}`);
92
+ }
93
+ }
94
+ else {
95
+ throw new Error('未知的文件存储类型');
96
+ }
97
+ const savedRecord = await this.mongodbService.insertOne(collectionName, {
98
+ _id,
99
+ original: {
100
+ type: mimeType,
101
+ size: file.size,
102
+ name: file.originalname,
103
+ md5,
104
+ },
105
+ metadata: {
106
+ owner: owner,
107
+ space: space,
108
+ record_id: record_id,
109
+ object_name: object_name,
110
+ parent: parent,
111
+ },
112
+ copies: {
113
+ files: {
114
+ name: file.originalname,
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 fileRecord = await this.mongodbService.findOne(collectionName, {
133
+ _id: fileId,
134
+ });
135
+ if (!fileRecord) {
136
+ throw new Error('未找到指定的文件记录');
137
+ }
138
+ if (this.cfsStore === 'S3') {
139
+ const key = fileRecord.copies.files.key;
140
+ const params = {
141
+ Bucket: this.s3Bucket,
142
+ Key: key,
143
+ Expires: 60 * 5,
144
+ };
145
+ try {
146
+ return this.s3.getSignedUrl('getObject', params);
147
+ }
148
+ catch (err) {
149
+ throw new Error(`生成 S3 签名 URL 失败: ${err.message}`);
150
+ }
151
+ }
152
+ else if (this.cfsStore === 'local') {
153
+ return (this.rootUrl +
154
+ '/api/v6/files/' +
155
+ collectionName +
156
+ '/' +
157
+ fileId +
158
+ '/' +
159
+ fileRecord.original.name);
160
+ }
161
+ return null;
162
+ }
163
+ async downloadFileStream(collectionName, fileId) {
164
+ const fileRecord = await this.mongodbService.findOne(collectionName, {
165
+ _id: fileId,
166
+ });
167
+ if (!fileRecord) {
168
+ throw new Error('未找到指定的文件记录');
169
+ }
170
+ if (this.cfsStore === 'local') {
171
+ try {
172
+ const key = fileRecord.copies.files.key;
173
+ const collectionFolderName = this.getCollectionFolderName(collectionName);
174
+ const fileUrl = path.join(this.storageDir, 'files', collectionFolderName, key);
175
+ if (!(await fs.pathExists(fileUrl))) {
176
+ throw new Error('文件不存在');
177
+ }
178
+ return fs.createReadStream(fileUrl);
179
+ }
180
+ catch (err) {
181
+ throw new Error(`文件下载失败: ${err.message}`);
182
+ }
183
+ }
184
+ else if (this.cfsStore === 'S3') {
185
+ const key = fileRecord.copies.files.key;
186
+ const params = {
187
+ Bucket: this.s3Bucket,
188
+ Key: key,
189
+ Expires: 60 * 60,
190
+ };
191
+ try {
192
+ const s3Object = this.s3.getObject(params);
193
+ return s3Object.createReadStream();
194
+ }
195
+ catch (err) {
196
+ throw new Error(`文件下载失败: ${err.message}`);
197
+ }
198
+ }
199
+ else {
200
+ throw new Error('未知的文件存储类型');
201
+ }
202
+ }
203
+ };
204
+ exports.FilesService = FilesService;
205
+ exports.FilesService = FilesService = FilesService_1 = __decorate([
206
+ (0, common_1.Injectable)(),
207
+ __metadata("design:paramtypes", [config_1.ConfigService,
208
+ mongodb_service_1.MongodbService])
209
+ ], FilesService);
210
+ //# 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,gEAA4D;AAE5D,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,GAAG,IAAI,eAAM,CAAC,cAAY,CAAC,IAAI,CAAC,CAAC;QAMtD,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,mBAAmB,CAAC;QAE1E,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC;QAC1D,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,IAAI,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;gBACnB,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,qBAAqB,CAAC;gBAClD,WAAW,EAAE,aAAa,CA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;gBACrB,GAAG,EAAE,GAAG;gBACR,OAAO,EAAE,EAAE,GAAG,EAAE;aACjB,CAAC;YAEF,IAAI,CAAC;gBAEH,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBAC3C,OAAO,QAAQ,CAAC,gBAAgB,EAAE,CAAC;YACrC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF,CAAA;AA9QY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAUc,sBAAa;QACZ,gCAAc;GAV7B,YAAY,CA8QxB"}
@@ -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,3 @@
1
+ export * from './files.controller';
2
+ export * from './files.module';
3
+ export * from './files.service';
@@ -0,0 +1,20 @@
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
+ //# 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"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './auth';
2
+ export * from './files';
2
3
  export * from './mongodb';
package/dist/index.js CHANGED
@@ -15,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth"), exports);
18
+ __exportStar(require("./files"), exports);
18
19
  __exportStar(require("./mongodb"), exports);
19
20
  //# 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,yCAAuB;AACvB,4CAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,0CAAwB;AACxB,4CAA0B"}
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@builder6/core",
3
- "version": "0.6.5",
3
+ "version": "0.7.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "dist"
8
8
  ],
9
+ "dependencies": {
10
+ "@builder6/query-mongodb": "^0.7.0"
11
+ },
9
12
  "scripts": {
10
13
  "build": "rm -rf dist && tsc -b",
11
14
  "build:watch": "rm -rf dist && tsc --watch"
@@ -13,5 +16,5 @@
13
16
  "publishConfig": {
14
17
  "access": "public"
15
18
  },
16
- "gitHead": "b4f7ff4cfa74b8d192b54e6488a136141d6ee661"
19
+ "gitHead": "d30a865347a5c71f33e0c337658bae231a8d271d"
17
20
  }