UNPKG

@tsed/common

Version:
52 lines 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MulterOptions = void 0; const core_1 = require("@tsed/core"); const PlatformMulterMiddleware_1 = require("../../middlewares/PlatformMulterMiddleware"); /** * Define multer option for all MultipartFile * * ```typescript * import {Controller, Post, PlatformMulterFile, MultipartFile, MulterOptions} from "@tsed/common"; * * @Controller('/') * class MyCtrl { * @Post('/file') * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile) { * * } * * @Post('/file') * @MulterOptions({dest: "/other-dir"}) * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile) { * * } * * @Post('/file2') * @MulterOptions({dest: "/other-dir"}) * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile, @MultipartFile("file2") file2: PlatformMulterFile) { * * } * * @Post('/files') * private uploadFile(@MultipartFile("file1") files: PlatformMulterFile[]) { * * } * } * ``` * * See the tutorial on the [multer configuration](/tutorials/multer.md). * * @param {multer.Options} options * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor} * @decorator * @multer */ function MulterOptions(options) { return (target, propertyKey, descriptor) => { core_1.StoreMerge(PlatformMulterMiddleware_1.PlatformMulterMiddleware, { options })(target, propertyKey, descriptor); return descriptor; }; } exports.MulterOptions = MulterOptions; //# sourceMappingURL=multerOptions.js.map