How to validate a file on S3 send by pre-signed URL?

Viewed 2069

I understand that a pre-signed URL is a way to send a file to S3. By doing that way, how can the object be validated? For example, I want to submit a JSON file to S3 and I want to make sure the file is in a correct format as input. I'd like to know if there is any way to make a response that the file is correctly saved and is valid by own validator function.

2 Answers

The best way to do this is to generate the pre-signed URL with GET and PUT permissions for the same object. First, you would fire the PUT request to upload the file to S3 bucket. Next, you can do a GET call to check that the file has been uploaded.

As long as you are uploading a fresh new file, there is no chance of getting a false positive.

The above concept is based on the fact that the pre-signed URLs are restricted by time validating and not by the number of requests. This allows you to perform any number of PUT and GET call to the file as you want until the URL is valid.

Note: S3 is a trustworthy service - As long as you get a 200 status for your PUT request, you can rest assured that your file is there. The above method is just to crosscheck in case you wish to

Related