Thursday 1 October 2020

Stop Image upload to S3 if username update fails in Multer s3

I am developing an app that requires image upload to S3 and the user can update his profile pic and username at the same time , my problem is how do you stop the image upload to aws S3 if the username update fails for some reason like having the same username existing in the database ie.duplicate keys , currently what i implemented was update the user image and get the location of the file in s3 and save that link in the database and if user updates his image i reach out to the s3 bucket and delete his previous file and the upload the new one , now the problem is if username update fails once and i try to update it again, the file gets uploaded to s3 and the name updates,but the user image doesnt and i never get a response from the server and end up having duplicate files in my bucket which is the old profile pic and the new pic which is undesirable, is there a solution?here is the stackoverflow post for code refrence , am outta luck here , i've been stuck with this for a while now :https://stackoverflow.com/questions/64155106/stop-image-upload-to-s3-if-username-update-fails-in-multer-s3

Submitted October 01, 2020 at 02:37PM by the_excelsior22

No comments:

Post a Comment