0

I use FilePicker (now called FileStack) and I wanted to know if it's possible to prevent duplicate file uploads to a single container. For example, if I allow users to up upload some music files, how do I prevent them from adding the same music file twice in the same upload instance? The starter code is below:

    filepicker.pickAndStore(
      {
       mimetype:"image/*",
       multiple: true
      },
      {
        location:"S3"
      },
      function(Blobs){
        console.log(JSON.stringify(Blobs));
      }
    );
Ryan Clark
  • 79
  • 5

1 Answers1

0

To only reliable way for finding duplicates would be compare files MD5 hashes.

MD5 hash is a unique identifier and it is available via filepicker API.

Example call:

https://www.filepicker.io/api/file/hFHUCB3iTxyMzseuWOgG/metadata?md5=true

Response:

{"md5": "f31dbf9b885e315d98e136f1db0daf52"}

To be even more reliable you can also compare file size. So what I would recommend is storing md5 hash and files size together with file links in the database.

krystiangw
  • 529
  • 5
  • 14