Use the browser JavaScript SDK to check if there is a file on the AWS S3?

I recently changed the naming convention of the files in the job folder. Since I need to support both the new naming convention and the old naming convention when a user tries to download a specific file, I need to check the new Does the naming standard URL exist? If not, download it from the old naming standard URL.

Is there a way to “ping” the S3 URL to see if a valid file is stored in the URL? Due to cross-domain issues, standard AJAX calls do not work.

The file I want to check is a binary file.

You can check the headObject() method in the AWS JavaScript SDK, but if the file is publicly accessible, you can also use a simple HEAD request (using ajax).

< p>You can solve the cross-domain problem by specifying the CORS policy on the bucket.

I recently changed the naming convention of the files in the job folder. Because when the user tries When downloading a specific file, I need to support both the new naming convention and the old naming convention. I need to check whether the new naming standard URL exists, and if it does not exist, download from the old naming standard URL.

< p>Is there a way to “ping” the S3 URL to see if a valid file is stored in the URL? Due to cross-domain issues, standard AJAX calls do not work.

The file I want to check is a binary file.

You can check AWS The headObject() method in the JavaScript SDK, but if the file is publicly accessible, you can also use a simple HEAD request (using ajax).

You can specify the CORS policy on the bucket To solve cross-domain issues.

Leave a Comment

Your email address will not be published.