1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-24 08:52:28 +02:00

fix(server): expand tests and add avi, mov to mimetypes. (#2213)

This commit is contained in:
Skyler Mäntysaari 2023-04-09 04:35:27 +03:00 committed by GitHub
parent a68fbcc520
commit fb42a736f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -102,6 +102,24 @@ describe('assetUploadOption', () => {
expect(callback).toHaveBeenCalledWith(null, true);
});
it('should allow .mov videos with video/mov mimetype', () => {
const file = { mimetype: 'video/mov', originalname: 'test.mov' } as any;
fileFilter(mock.userRequest, file, callback);
expect(callback).toHaveBeenCalledWith(null, true);
});
it('should allow .avi videos with video/avi mimetype', () => {
const file = { mimetype: 'video/avi', originalname: 'test.avi' } as any;
fileFilter(mock.userRequest, file, callback);
expect(callback).toHaveBeenCalledWith(null, true);
});
it('should allow .avi videos with video/x-msvideo mimetype', () => {
const file = { mimetype: 'video/x-msvideo', originalname: 'test.avi' } as any;
fileFilter(mock.userRequest, file, callback);
expect(callback).toHaveBeenCalledWith(null, true);
});
it('should not allow unknown types', async () => {
const file = { mimetype: 'application/html', originalname: 'test.html' } as any;
const callback = jest.fn();

View File

@ -56,7 +56,7 @@ function fileFilter(req: Request, file: any, cb: any) {
}
if (
file.mimetype.match(
/\/(jpg|jpeg|png|gif|mp4|webm|x-msvideo|quicktime|heic|heif|dng|x-adobe-dng|webp|tiff|3gpp|nef|x-nikon-nef|x-fuji-raf|x-samsung-srw|mpeg|x-flv|x-ms-wmv|x-matroska)$/,
/\/(jpg|jpeg|png|gif|avi|mov|mp4|webm|x-msvideo|quicktime|heic|heif|dng|x-adobe-dng|webp|tiff|3gpp|nef|x-nikon-nef|x-fuji-raf|x-samsung-srw|mpeg|x-flv|x-ms-wmv|x-matroska)$/,
)
) {
cb(null, true);