Closed jvnlwn closed 7 months ago
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.
Thanks @Borewit, that makes sense. Guessing the behavior is expected in filestack-js – maybe they intend for the library to be used in either a Web or Node.js env.
In a recent release of filestack-js (v 3.29.0) https://github.com/filestack/filestack-js/commit/ec8a95001647bd1f5fc2d2a68f55da26b541e0b5, 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.