I've successfully set up a direct PDF file upload from the client's machine to Amazon S3 using only Go language. Everything is working as expected, but there's one thing that concerns me... Here are the steps:
User clicks on the PDF button
A new browser tab opens with an HTML page (which shows "generating your report")
In the background, the PDF file is uploading to S3. The API returns the S3 URL to the client.
Issue
How can I verify if the URL is active or not yet? If it returns a 404 error, I don't want to redirect immediately... I want to wait for another N seconds. Only when it returns a 200 status code should I redirect to the S3 URL.
Is there a way to achieve this using JavaScript?