Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image/svg+xml mimetype converting into application/xml #61

Open
VarshaJatav opened this issue Aug 26, 2024 · 2 comments
Open

image/svg+xml mimetype converting into application/xml #61

VarshaJatav opened this issue Aug 26, 2024 · 2 comments

Comments

@VarshaJatav
Copy link

I am using HasMimeType decorator of 'nestjs-form-data' in dto.
@HasMimeType([
'image/bmp',
'image/gif',
'image/jpeg',
'image/png',
'image/webp',
'image/svg+xml',
])

When uploading the svg file of mime type 'image/svg+xml', I was getting validation error of mimetype.
Error message -> "File must be of one of the types image/bmp, image/gif, image/jpeg, image/png, image/webp, image/svg+xml"

I tried to check the mimetype of image by commenting this decorator, so I found that it was converting the mimetype 'image/svg+xml' to 'application/xml' which violates the validations.

Console message of the file uploaded ->
FileSystemStoredFile {
originalName: 'image.svg',
encoding: '7bit',
busBoyMimeType: 'image/svg+xml',
path: '/home/Documents/project/image.svg',
size: 100314,
fileType: { ext: 'xml', mime: 'application/xml' }
}

This is problematic as we are using the fileType.ext extension to save the file to our database and when this is streamed, the image is unrenderable as the path now refers to a file with extension .xml instead of the correct .svg.

@VarshaJatav
Copy link
Author

@dmitriy-nz Please look into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@VarshaJatav and others