1

I am trying to find an optimal way to handle the following scenario:

I have an application where there are a lot of file uploads on a certain endpoint, but the validation is rather strict as per the format and quality of the uploaded files, so a lot of the uploads fail, but for dozens of different validation problems.

I am currently designing a solution in the following manner:

Wrap the responsible service method in a try-catch block, and if one error occurs, persist the broken file in a new db table for subsequent investigation, then rethrow the exception and do the rollback for the transaction. The db table can be purged constantly, so the files are stored only for investigation then dropped.

Do you see a better solution for investigating bad uploads?

0

1 Answer 1

2

What you can do is Upload first , validate later aproach.

At first your client will upload the file on the server at a staging location and will answer with response OK and url where the client will have the capability to retrieve the result of the validation when it is available. In the background you will triger a validation task on the server performing al the check that will at the end copy the file from the staging location to your final location.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.