question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't allow duplicates of a file

See original GitHub issue

Feature Request

Describe the solution you’d like

There should be a way to make sure users can’t upload 2 of the same files.

Describe alternatives you’ve considered

I’ve tried to do this outside of the dropzone, but there doesn’t seem to a way.

Teachability, Documentation, Adoption, Migration Strategy

It could just be a prop passed in called noDuplicates

Additional context

See my stack overflow question here: https://stackoverflow.com/questions/63198613/how-do-i-make-a-material-ui-dropzone-area-not-allow-duplicates

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
Sheshank-scommented, Aug 10, 2020

Since this is something many people would need, don’t you think it would be best to implement it as a feature?

1reaction
jrhager84commented, Feb 14, 2021

Here is the boilerplate for you to use to filter out duplicates. Use DropzoneAreaBase instead to add your own handler for the onAdd onDelete methods.

  function addSongs(newSongs) {
    newSongs = newSongs.filter(song => !songs.find(f => f.data === song.data));
    setSongs([...songs, ...newSongs]);
  }

  function removeSong(deleted) {
    setSongs(songs.filter(f => f !== deleted))
    console.log(songs)
  }

this is using state via [songs, setSongs] for the fileObjects prop

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Preventing Duplicate List<T> Entries - Stack Overflow
List<T> does indeed allow duplicates. In the case of FileInfo , the Contains method will be checking whether the references are the same, ......
Read more >
How to prevent duplicates in a column in Excel - Ablebits
Select the entire column where you need to avoid duplicates. Click on the first cell with data keeping the Shift keyboard button pressed...
Read more >
How to stop files from creating duplicates on an external hard ...
saved on my external hard drive, it seems to be making a copy/duplicate of each file with a ._ in front of the...
Read more >
Prevent Duplicate Entries in Excel (Easy Tutorial)
In the Allow list, click Custom. 4. In the Formula box, enter the formula ... This value may only occur once (=1) since...
Read more >
How can I prevent duplicate files on my c… - Apple Community
Start in the Songs view. Use File > Library > Show Duplicate Items and then click Same Album to display exact duplicates as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found