"Is there a way to verify if a file has been successfully uploaded to an S3 bucket

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?

Answer №1

AWS S3 ensures consistency by providing read-after-write for new objects. Source: https://aws.amazon.com/s3/faqs/

" Q: What data consistency model does Amazon S3 follow?

Amazon S3 buckets offer read-after-write consistency for new object uploads and eventual consistency for overwrite PUTS and DELETES. "

This guarantees that your uploaded object will be accessible. To verify the object's presence on S3 using JavaScript, you can make an Ajax request within the same domain or enable CORS on your S3 bucket. Details are available here: http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html.

If not, a server-side component is required to verify the upload status of the object and communicate with JS in the same domain.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Arrow indicating the correct direction to expand or collapse all items with a single click

I have successfully implemented the "expand/collapse all" function, but I am facing an issue with the arrow direction. The arrows are not pointing in the correct direction as desired. Since I am unsure how to fix this problem, I have left it empty in my co ...

To optimize the code, consider replacing the file:///home/ishan/.../node_modules/chai/index.mjs require statement with a dynamic import() function that can be used in all CommonJS modules

Currently, I am using the newest version of Hardhat on WSL. Following the demonstration provided by Hardhat, I have installed the npm packages for hardhat toolbox. However, I am encountering an error that is unclear to me. Initially, I was utilizing the & ...

How to retrieve a value from a getter in a different file using Node.js

Recently, during the creation of a node project, I defined a model as follows: export default class Tokens { constructor() { this.accessToken = ''; this.refreshToken = ''; } getAccessToken() { return ...

How to send a DOM element's value to an AJAX request using HTML.PagedList parameters

As I delve into learning ajax requests, I find myself questioning if I am on the right track. Currently, I have a page that incorporates pagination, sorting, and searching functionalities. My goal is to implement these features using ajax to avoid reloadin ...

Is there a way to extract the unicode/hex representation of a symbol from HTML using JavaScript or jQuery?

Imagine you have an element like this... <math xmlns="http://www.w3.org/1998/Math/MathML"> <mo class="symbol">α</mo> </math> Is there a method to retrieve the Unicode/hex value of alpha α, which is &#x03B1, using JavaScrip ...

Unlocking the parent scope in a custom attribute directive

I am new to utilizing angular js. I came across a similar inquiry on How to access parent scope from within a custom directive *with own scope* in AngularJS? However, the solution provided did not work for my basic test. Here is the sandbox. http://jsfi ...

How can I easily move from a shared page to a specific page in Angular 8?

Just stepping into the world of front-end development, I have a scenario where my menu page offers 3 options to navigate: Go to Arena. Go to Dungeon. Go to Battleground. However, clicking on any of these options leads me to a common page for character p ...

How to Customize the Navbar Position in Bootstrap 3 when the Brand/Logo is Collapsed

I am currently in the process of creating my first website and experimenting with the Bootstrap 3 framework. The navbar I have selected is designed to adjust based on screen size, collapsing into a small button for use on tablets and mobile devices. Howe ...

Change the appearance of text with a button click using JavaScript

Currently mastering JavaScript but encountering an issue. How do I change the text to underline when clicking on "Click Me"? <p id="demo" style=" text-decoration:none; ">Hello JavaScript!</p> <button type="button" onclick="document.getE ...

Exploring the Versatility of the IN Operator in Jquery and Javascript

RatecardIDs=[2, 22, 23, 25]; if (parseInt(cellValue) in (RatecardIDs)) { } Is it possible to use the In operator in an if condition? This code first executes the code in the if block, but then it goes on to the else block. ...

Use jQuery to set a Firebase image as the background of a div element

Is there a way to fetch an image from Firebase and use it as the background for a div element? I've tried several approaches without success. Could someone share some examples on how to achieve this? <div class="museBGSize rounded-corners grpelem" ...

Issue with Event.target not functioning properly when clicking outside the div to close it

I am facing an issue with my main div and sub div, which is referred to as a form because it is enclosed within the main div. I am trying to close the form when clicking outside of the main div, but unfortunately, this functionality is not working as expec ...

As I attempt to connect with the bitcoin average server, I encounter a 403 status code error in the communication

const express = require("express"); const bodyParser = require("body-parser"); const request = require("request"); const app = express(); app.use(bodyParser.urlencoded({extended: true})); app.get("/", function(req, res){ res.sendFile(__dirname + "/inde ...

Is there a Node ORM that supports application-side joins?

Initially, I experimented with Loopback and found it to be a useful tool. However, one limitation I encountered is that it does not support relationships across multiple REST data services. Instead, Loopback makes a call to the initial data service and pas ...

What happens when you click on paper-tabs in a polymer?

Struggling to get click events to fire on <paper-tabs> and <paper-tab>. Interestingly, when manually adding event listeners in Chrome's developer tools, it works fine. But the same code doesn't seem to work in my application: // app. ...

Tips for navigating back and forth on a support page by utilizing reaction await in discord.js

Here is an example of my code snippet: const Discord = require('discord.js') module.exports = { name: 'help', description: 'help', execute(message, args) { const embed = new Discord.MessageEmbed() ...

Switch the 360-degree images by clicking a button using Panolen.js

As a beginner in the world of html, css, and javascript, I am trying to create a webpage that displays 360 panorama images. My goal is to have the image change when a button is clicked - for example, clicking on button 1 will display image1, while clicking ...

Parent menu fails to trigger the opening of child menu upon clicking

I'm struggling to modify a Wordpress theme to enable the child menus to expand when clicking on the parent menus. Is there a way to edit this code to make that functionality work? // Implement expandable menus var expand_link = $('<a class="m ...

How to Resubmit a Form Using Ajax?

My form utilizes ajax to call the server for user authentication. However, I've encountered an issue where if a user enters the wrong password and then tries to correct it, any subsequent calls do not trigger the on('submit') function, leavi ...

What are the steps to start a ExpressJS server for webpages that are not index.html?

I am exploring how to browse/run/view web pages other than just the index.html file in my public folder, which contains multiple HTML files. I am using ExpressJS and NodeJS for this purpose, but every time I start my server, I can only access the index.htm ...