I recently changed the naming convention for a file in my job folders. Since I need to support both the new naming convention and the old naming convention when a user tries to download the specific file, I need to check if the new naming standard URL exists and if not, download from the old naming standard URL.
Is there a way to 'ping' a S3 URL to see if a valid file is stored at the URL? Standard AJAX calls doesn't work because of cross-domain issues.
The files I am checking for are binary files.
You can have a look at the headObject() method in the AWS JavaScript SDK, but if the file is publicly accessible, a simple HEAD
request (using ajax) will also do.
You can work out the cross domain issues by specifying a CORS policy on your bucket.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With