Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
laurent22 opened this issue Jun 24, 2024 · 2 comments · Fixed by #10907
Closed

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

laurent22 opened this issue Jun 24, 2024 · 2 comments · Fixed by #10907
Assignees
Labels
bug It's a bug desktop All desktop platforms high High priority issues

Comments

@laurent22
Copy link
Owner

laurent22 commented Jun 24, 2024

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.

@laurent22 laurent22 added bug It's a bug desktop All desktop platforms high High priority issues labels Jun 24, 2024
@laurent22 laurent22 changed the title set mime type of non-images when creating resources from API Set mime type of non-images when creating resources from API Jun 24, 2024
@pedr pedr self-assigned this Aug 15, 2024
@pedr
Copy link
Collaborator

pedr commented Aug 16, 2024

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
Copy link
Contributor

marph91 commented Sep 14, 2024

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:

  • binary files: Any binary files that can't be classified by the "file-type" package -> application/octet-stream
  • text-based files: Any text file -> Could be a general text/plain, just to avoid having application/octet-stream assigned to them

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

laurent22 added a commit that referenced this issue Nov 7, 2024
#10907)

Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug desktop All desktop platforms high High priority issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants