Closed julianpoemp closed 1 year ago
Hi! Can you confirm that the new version detects the correct mime type for your file?
@dmitriy-nz can't create a custom build of nestjs-form-data with the latest file-type package. Building with npm run build
doesn't create a valid package. The build can't be installed via npm link
or as archive in my project.
@dmitriy-nz found a way to create valid packages (using npm pack
).
There is a huge ESM problem with file-type imports in commonjs packes so I can't use the latest version because I get the error as described here . There are a lot of issues discussed in file-type where a lot of people don't recommend to update it as long as you are using commonjs. I think this will be an issue in the future.
Furthermore I found out that the "correct" mime types for audio/wave and audio/x-wave should be audio/vnd.wave
according to this PR. So I changed the valid mime types an my side and now it works.
The
loadFile()
function in FormReader.ts reads a wrong mime type from a stream. In my case it'saudio/vnd.wave
instead ofaudio/wave
. That leads to a failingHasMimeType
validation.I assume it's a bug from the
file-type
package. You are using an old version, v16.5.4, perhaps this issue is solved if you upgrade to the latest version?I tested it uploading a file using FileSystemStorage and a DTO that uses the
HasMimeType
decorator. I'm currently using nestjs-form-data@1.8.3 and NestJS@9.0.11 with platform-express@9.0.11As a workaround I downgraded back to nestjs-form-data@1.7.1.