Back

[SOLVED] Compare uploaded file with to-be uploaded file

  • 0
  • Web
  • Storage
Said H
4 Jun, 2023, 04:28

Hello, i referred to the documentation, and understood that updateFile does not actually replace the file content.

I have a form that let user upload file, and the form can be edited too.

During the edit, I am trying to compare the existing uploaded file against the file that will be uploaded. Would you have any suggestion what is the recommended way to compare the existing file against the file to be uploaded?

using filename to compare is not appropriate because user can reupload a different file but maintain the same filename. I feel that it may be computationally expensive to download the full file from AppWrite and compare it against the new file everytime someone edit the form. And would rather do an updateFile instead. However, updateFile does not currently overwrite the uploaded file. Would you have any advice for me?

thanks a lot

TL;DR
The user is asking for a way to compare an existing uploaded file with a file that will be uploaded in the future. They mention that comparing the filenames is not appropriate because the user can upload a different file with the same name. They prefer not to download the entire file from AppWrite and compare it each time. A suggested solution is to use the MD5 signature to compare the files. Additionally, the user mentions that the updateFile function does not replace the file content. Solution: Use the MD5 signature to compare the existing uploaded file and the to-be uploaded file.
Susmita
4 Jun, 2023, 04:29

Hello @Said H When you're uploading a file, a file id is being automatically creating and the file is being stored in the Appwrite storage

Susmita
4 Jun, 2023, 04:30

Since, you want to update the image, make sure that you have an attribute called image or imageID in your collection

Susmita
4 Jun, 2023, 04:30

which will get updated with the updated image id

Susmita
4 Jun, 2023, 04:30

and get rendered properly on form submit

Susmita
4 Jun, 2023, 04:31

Hope this helps

Drake
4 Jun, 2023, 04:39

Get file returns data about the file including an md5 hash. Maybe that will help?

https://appwrite.io/docs/client/storage?sdk=web-default#storageGetFile

Said H
4 Jun, 2023, 05:04

thanks @Susmita and @Steven MD5 signature does help perfectly!

Said H
4 Jun, 2023, 05:04

[SOLVED] Compare uploaded file with to-be uploaded file

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more