react-csv-importer icon indicating copy to clipboard operation
react-csv-importer copied to clipboard

Feat: file validation

Open MusabShakeel576 opened this issue 3 years ago • 9 comments

Summary: Allows specific file formats to be previewed.

Issue: #79

Checklist

  • [x] Unit tests updated
  • [x] Localization updated

MusabShakeel576 avatar Nov 19 '22 15:11 MusabShakeel576

Hi Musab, thanks a lot for contributing! Looks really useful, I'll just need to do a deeper check on this before merging. By the way, does this validation check for specific file extensions or just MIME type?

unframework avatar Nov 20 '22 05:11 unframework

Hi Nick,

does this validation check for specific file extensions or just MIME type?

It checks for specific file types.

https://github.com/beamworks/react-csv-importer/blob/c8abd250aeb009a14c2009962629220709e52bb1/src/components/file-step/FileSelector.tsx#L15

https://github.com/beamworks/react-csv-importer/blob/c8abd250aeb009a14c2009962629220709e52bb1/src/components/file-step/FileSelector.tsx#L24

MusabShakeel576 avatar Nov 20 '22 07:11 MusabShakeel576

Hey, thanks again for making this change. There are a couple tweaks I would need before we can merge this:

  • the list of file types should be a configurable option (and maybe have file extensions too)
  • react-dropzone has options to help this, we should use them too: https://react-dropzone.js.org/#!/Accepting%20specific%20file%20types
  • indentation in FileSelector.tsx was affected - I have a PrettierJs config in the repo that should help auto-format it

I can make the necessary commits to augment your PR (no timing guarantee of course) or if you want to do it yourself then feel free as well. Thanks!

unframework avatar Feb 23 '23 20:02 unframework

I think only file format should be accepted is csv files. Because(https://github.com/beamworks/react-csv-importer/issues/79#issuecomment-1553549183) That can be achieved that PR as I see or using useDropzone ability like below:

const acceptedFiles = {
"text/csv": [".csv"]
}

  const { getRootProps, getInputProps } = useDropzone({
...
    accept: acceptedFiles,
...
  })

devLeopar avatar May 18 '23 19:05 devLeopar

@unframework could you please deploy it?

devLeopar avatar May 30 '23 14:05 devLeopar

Any chance we can get this deployed?

dwene avatar Jun 26 '23 17:06 dwene

@MusabShakeel576 it looks like there are conflicts in this PR. Could you resolve those please so we could maybe get this merged?

dwene avatar Jun 26 '23 17:06 dwene

Hey everyone, looks like this feature is getting continued attention, thanks for all the suggestions. There are still some small issues outstanding with the PR (see my earlier comment) and as @dwene pointed out it has a conflict now. I will try to find some time this week to tweak the PR.

unframework avatar Jun 27 '23 05:06 unframework

I fixed the PR conflicts in a fork if you want to use any of that code.

https://github.com/adsupnow/react-csv-importer

dwene avatar Jun 27 '23 16:06 dwene