frictionless-js icon indicating copy to clipboard operation
frictionless-js copied to clipboard

Add support for other extensions except CSV for uploaded files

Open kmanaseryan opened this issue 4 years ago • 5 comments

Currently in the calls dedicated for uploaded files the csv format is hardcoded. We need to make it so the format will be automatically generated from the mime type.

Acceptance criteria

  • [ ] If I pass anything than CSV file the format should be the appropriate extension

Tasks

  • [ ] Read mime type from the file and generate the format

kmanaseryan avatar Sep 11 '20 12:09 kmanaseryan

Here is another fix for this - https://github.com/datopian/data.js/commit/db55e8cbe45aea30e564325f84a3035df8a151c9 which uses file extension to detect file format. I'm not sure if using mimetype is a good idea.

anuveyatsu avatar Sep 15 '20 11:09 anuveyatsu

@kmanaseryan Please, feel free to close this issue as fixed if you believe so.

anuveyatsu avatar Sep 15 '20 11:09 anuveyatsu

@anuveyatsu there is lib which does job for us: https://www.npmjs.com/package/mime-types. If the extensions are known and they are few, we can actually hardcode them in a list and get the format from there, but if they are going to be arbitrary extensions then I think it worth to use the lib.

kmanaseryan avatar Sep 15 '20 11:09 kmanaseryan

@kmanaseryan yes and we're actually using that lib already https://github.com/datopian/data.js/blob/master/package.json#L53 and https://github.com/datopian/data.js/blob/b03836de6b3291173d2c37901456ba5f5aeb2baf/src/index.js#L369

I'm not sure about that lib because it might be just mapping file extension to mime-type.

anuveyatsu avatar Sep 15 '20 11:09 anuveyatsu

@anuveyatsu cool, haven't noticed that, so we can use it then.

I'm not sure about that lib because it might be just mapping file extension to mime-type.

I think the lib is more safe than we do it on ourselves, becuase two different mime types can have one extension, so this lib I believe handles that.

kmanaseryan avatar Sep 15 '20 11:09 kmanaseryan