beamworks / react-csv-importer

Uploader + CSV parser + raw file preview + UI for custom user column mapping, all in one
https://www.npmjs.com/package/react-csv-importer
MIT License
231 stars 95 forks source link

Feat: file validation #90

Open MusabShakeel576 opened 1 year ago

MusabShakeel576 commented 1 year ago

Summary: Allows specific file formats to be previewed.

Issue:

79

Checklist

unframework commented 1 year ago

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?

MusabShakeel576 commented 1 year ago

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

unframework commented 1 year ago

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

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!

devLeopar commented 1 year ago

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 commented 1 year ago

@unframework could you please deploy it?

dwene commented 1 year ago

Any chance we can get this deployed?

dwene commented 1 year ago

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

unframework commented 1 year ago

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.

dwene commented 1 year ago

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

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