Skip to content

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

Description

@VarshaJatav

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions