-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
proposal: expose mime-type <-> extension relations #598
Comments
What's the use-case? |
So basically we have two-stage file upload
In the control panel, where restrictions for fields are configured - we have a dropbox with a list of extensions that are supported by Previously we've been using We could store the extension detected by |
also, (i was planning to make another issue for that) - it would be great if the minimum sample size would be exposed for each |
The mapping cannot work in all cases though. There may be multiple extension for a single MIME type. I think what we can do is to expose all the data and let it be up to you to create a mapping if you need it. Currently, we expose: https://github.com/sindresorhus/file-type/blob/main/supported.js We could also expose an array of supported types, where each type is an object with certain properties: [
{
mimeType: 'image/jpeg',
extension: 'jpg',
minimumBytes: 4
},
...
] We could also use this to expose the minimum required bytes. |
Second solution - wil list of all detectable mime and extensions is most versatile one i suppose. i understand that mime <-> ext isnt one-to-one relation, therefore variant with exposing detectable pairs wold be the best i think. thanks for the library by the way - it saved me crapton of effort at the moment |
Note that the minimum required bytes, as they appear in the comments are in many cases only used for the initial identification. A second identification which may require an undetermined number of bytes may follow. There is also a single case which is using recursion (id3 header). Regarding customising the returned file types (eg extension). I think we should ask the question: does this really add value, or are we just hiding some extra code a user could add outside file-type to achieve the same thing. |
As for now - sets of supported mimetypes and extensions exposed, but not relation between them.
I think it will be useful to expose maps that will expose relation between extension and mimetype and vice-versa.
The text was updated successfully, but these errors were encountered: