How to use the @nestjs/swagger.ApiImplicitFile function in @nestjs/swagger

To help you get started, we’ve selected a few @nestjs/swagger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NarHakobyan / awesome-nest-boilerplate / src / modules / auth / auth.controller.ts View on Github external
type: LoginPayloadDto,
        description: 'User info with access token',
    async userLogin(
        @Body() userLoginDto: UserLoginDto,
    ): Promise {
        const userEntity = await this.authService.validateUser(userLoginDto);

        const token = await this.authService.createToken(userEntity);
        return new LoginPayloadDto(userEntity.toDto(), token);

    @ApiOkResponse({ type: UserDto, description: 'Successfully Registered' })
    @ApiImplicitFile({ name: 'avatar', required: true })
    async userRegister(
        @Body() userRegisterDto: UserRegisterDto,
        @UploadedFile() file: IFile,
    ): Promise {
        const createdUser = await this.userService.createUser(

        return createdUser.toDto();

github neoteric-eu / nestjs-auth / src / app / media / media.controller.ts View on Github external
import {MediaUploadDto} from './dto/media-upload.dto';

export class MediaController {

	private logger = new AppLogger(;

	constructor(@Inject(AWS_CON_TOKEN) private readonly awsConnection) {}

	@ApiImplicitFile({ name: 'media', required: true, description: 'Any media file' })
	@ApiResponse({ status: 200, description: 'OK', type: MediaUploadDto })
	public uploadFile(@UploadedFile() file) {
		return file;

	@MessagePattern({ cmd: MEDIA_CMD_DELETE })
	public async onMediaDelete(homeMedia: HomeMediaEntity): Promise {
		const key = new URL(homeMedia.url).pathname.substring(1);
		this.logger.debug(`[onMediaDelete] Going to remove key ${key} from bucket ${}`);
		const s3 = new S3();
			Key: key
		}).promise().then(() => {
			this.logger.debug(`[onMediaDelete] item with key: ${key} removed from bucket`);
		}).catch(() => {
github ZhiXiao-Lin / nestify / server / src / api / controllers / storage.controller.ts View on Github external
import { resolve } from 'path';
import { UploadActionType, StorageType } from '../../common/aspects/enum';
import { ImportService } from '../../common/services/import.service';
import { Logger } from '../../common/lib/logger';
import { Qiniu } from '../../common/lib/qiniu';

export class StorageController {
	constructor(private readonly importService: ImportService) { }

	@ApiImplicitFile({ name: 'file', required: true })
	async upload(@Req() req, @Res() res) {
		const files = req.raw.files;

		if (Object.keys(files).length == 0) {
			throw new BadRequestException('没有上传任何文件');

		const file = files.file;
		const action = req.raw.body.action || UploadActionType.UPLOAD;

		switch (action) {
			case UploadActionType.IMPORT:
				const target =;
				if (!target) throw new BadRequestException('参数 target 缺失');

				Logger.log(target, 'StorageController::import');