fix: 修复上传文件名乱码的问题
自动部署 / build (push) Failing after 2s
Details
自动部署 / build (push) Failing after 2s
Details
parent
2fd52a3d98
commit
785ed04ccb
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -11,12 +11,12 @@ export class LoginLogInterceptor implements NestInterceptor {
|
|||
tap({
|
||||
next: (data) => {
|
||||
const status = true;
|
||||
const description = '登录成功';
|
||||
const description = '用户登录成功';
|
||||
this.recordLoginLog(context, { status, description });
|
||||
},
|
||||
error: (err) => {
|
||||
const status = false;
|
||||
const description = err?.message || '登录失败';
|
||||
const description = err?.message || '用户登录失败';
|
||||
this.recordLoginLog(context, { status, description });
|
||||
},
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
import { ConfigService } from '@/config';
|
||||
import { dayjs } from '@/libraries';
|
||||
import { Module, forwardRef } from '@nestjs/common';
|
||||
import { MulterModule } from '@nestjs/platform-express';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { existsSync, mkdirSync } from 'fs';
|
||||
import { diskStorage } from 'multer';
|
||||
import { extname, join } from 'path';
|
||||
import { FileCategoryModule } from '../fileCategory';
|
||||
import { File } from './entities/file.entity';
|
||||
import { FileController } from './file.controller';
|
||||
import { FileService } from './file.service';
|
||||
import { dayjs } from '@/libraries';
|
||||
import { FileCategoryModule } from '../fileCategory';
|
||||
|
||||
const MulteredModule = MulterModule.registerAsync({
|
||||
useFactory: (config: ConfigService) => {
|
||||
return {
|
||||
useFactory: (config: ConfigService) => ({
|
||||
storage: diskStorage({
|
||||
destination: (req, file, next) => {
|
||||
const dest = join(config.uploadDir, dayjs().format(dayjs.DATE));
|
||||
|
|
@ -26,8 +25,11 @@ const MulteredModule = MulterModule.registerAsync({
|
|||
next(null, Date.now() + extname(file.originalname));
|
||||
},
|
||||
}),
|
||||
};
|
||||
fileFilter(req, file, callback) {
|
||||
file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf-8');
|
||||
callback(null, true);
|
||||
},
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue