laurent22 / joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.
https://joplinapp.org
Other
46.11k stars 5.02k forks source link

Set mime type of non-images when creating resources from API #10653

Closed laurent22 closed 1 week ago

laurent22 commented 4 months ago

Currently, when calling POST /resources, only the mime type of images is automatically detected. PDF for example are not detected, unless they end with the ".pdf" extension.

We should investigate whether we can automatically detect the mime type based on the file signature (there's probably an npm package for this). If the imported package is not too large that would be the preferred solution.

pedr commented 3 months ago

I guess the best package to do that would be file-type, it has a lot of downloads, has only 4 dependencies (and each one has at most 2 dependencies), a pretty extensive list of formats.

Would be interesting to think what are the most common type of format that should be supported, I guess most of the times it will PDF or a document file like Microsfot Word/Excel (which is supported by the package, excluding older versions) and .odf/.ods (Libre/OpenOffice, etc).

marph91 commented 2 months ago

Would be interesting to think what are the most common type of format that should be supported

In my case it's mostly PDF and images. The "file-type" package covers them.

In general, it can be any type. So personally, I would like another differentiation between:

I'm not sure how much effort a robust implementation in JS would require, though. Maybe some package, like isutf8 could be used.