Skip to content

Commit

Permalink
fix : uploadMusic, uploadImage 복구
Browse files Browse the repository at this point in the history
  • Loading branch information
khw3754 committed Nov 27, 2023
1 parent ca60da6 commit 21d90ed
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions server/src/upload/upload.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ import {
Query,
HttpCode,
UseGuards,
Post,
UseInterceptors,
UploadedFile,
ParseFilePipe,
FileTypeValidator,
} from '@nestjs/common';
import { UploadService } from './upload.service';
import { HTTP_STATUS_CODE } from 'src/httpStatusCode.enum';
import { AuthGuard } from '@nestjs/passport';
import { v4 } from 'uuid';
import { CatchyException } from 'src/config/catchyException';
import { ERROR_CODE } from 'src/config/errorCode.enum';
import { FileInterceptor } from '@nestjs/platform-express';

@Controller('upload')
export class UploadController {
Expand Down Expand Up @@ -51,4 +57,38 @@ export class UploadController {
throw error;
}
}

@Post('/music')
@UseInterceptors(FileInterceptor('file'))
async uploadMusic(
@UploadedFile(
new ParseFilePipe({
validators: [
// new MaxFileSizeValidator({ maxSize: fileSize.MUSIC_FILE_LIMIT_SIZE }),
new FileTypeValidator({ fileType: 'audio/mpeg' }),
],
}),
)
file: Express.Multer.File,
) {
const { url } = await this.uploadService.uploadMusic(file);
return { url };
}

@Post('/image')
@UseInterceptors(FileInterceptor('file'))
async uploadImage(
@UploadedFile(
new ParseFilePipe({
validators: [
// new MaxFileSizeValidator({ maxSize: fileSize.IMAGE_FILE_LIMIT_SIZE }),
new FileTypeValidator({ fileType: 'image/png' }),
],
}),
)
file: Express.Multer.File,
) {
const { url } = await this.uploadService.uploadImage(file);
return { url };
}
}

0 comments on commit 21d90ed

Please sign in to comment.