mimetype of certain PNGs mislabeled as "text/plan"
jvnlwn opened this issue · 5 comments
In a recent release of filestack-js (v 3.29.0) filestack/filestack-js@ec8a950, a bug was introduced when upgrading their file-type dependency.
When uploading certain PNGs via the filestack-js API, a PNG's mimetype might be mislabeled as "text/plan" rather than "image/png".
Here is a PNG which produced the error:
I cannot currently point to a change in file-type responsible, or provide a reproduction with file-type as I'm quite unfamiliar with this codebase.
The bug cannot be reproduced with filestack-js v 3.28.0, hence my suspicion leads me to file-type.
I tried adding the image to our tests and it's correctly detected as PNG.
@sindresorhus thank you for checking on that. It seems likely then that the bug lies with filestack-js. Will continue investigating with them, thanks!
@sindresorhus there could still be an issue with file-type which maybe you can help determine.
Once again, looking at the changes in filestack-js, especially take note of these changes.
In my testing with filestack-js, using the file in this issue's description, I hit the exception caught from file-type's fromBuffer
method.
In the console, I see the warning:
An exception occurred while processing the buffer: Buffer is not defined
The "Buffer is not defined" error could only be coming from file-type, no?
file-type is primary written for Node.js and has a dependency on node:Buffer.. At this time it required you properly shim the Buffer requirement in a non Node.js environment.