mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 00:50:23 -05:00
fix(server) utf8 original filename (#1147)
This commit is contained in:
parent
354593a70d
commit
21d6874e54
3 changed files with 9 additions and 0 deletions
|
@ -7,6 +7,7 @@ import { existsSync, mkdirSync } from 'fs';
|
|||
import { diskStorage } from 'multer';
|
||||
import { extname, join } from 'path';
|
||||
import sanitize from 'sanitize-filename';
|
||||
import { patchFormData } from '../utils/path-form-data.util';
|
||||
|
||||
export const assetUploadOption: MulterOptions = {
|
||||
fileFilter,
|
||||
|
@ -55,6 +56,8 @@ function filename(req: Request, file: Express.Multer.File, cb: any) {
|
|||
return cb(new UnauthorizedException());
|
||||
}
|
||||
|
||||
file.originalname = patchFormData(file.originalname);
|
||||
|
||||
const fileNameUUID = randomUUID();
|
||||
|
||||
if (file.fieldname === 'livePhotoData') {
|
||||
|
|
|
@ -6,6 +6,7 @@ import { existsSync, mkdirSync } from 'fs';
|
|||
import { diskStorage } from 'multer';
|
||||
import { extname } from 'path';
|
||||
import sanitize from 'sanitize-filename';
|
||||
import { patchFormData } from '../utils/path-form-data.util';
|
||||
|
||||
export const profileImageUploadOption: MulterOptions = {
|
||||
fileFilter,
|
||||
|
@ -49,6 +50,8 @@ function filename(req: Request, file: Express.Multer.File, cb: any) {
|
|||
return cb(new UnauthorizedException());
|
||||
}
|
||||
|
||||
file.originalname = patchFormData(file.originalname);
|
||||
|
||||
const userId = req.user.id;
|
||||
const fileName = `${userId}${extname(file.originalname)}`;
|
||||
|
||||
|
|
3
server/apps/immich/src/utils/path-form-data.util.ts
Normal file
3
server/apps/immich/src/utils/path-form-data.util.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export function patchFormData(latin1: string) {
|
||||
return Buffer.from(latin1, 'latin1').toString('utf8');
|
||||
}
|
Loading…
Reference in a new issue