Here is how you can access a public file on S3 in React.js:
fetch('https://bucketnmame.s3.amazonaws.com/folder1/folder2/file.txt')
.then ((response) => response.text())
.then (data => {
console.log(data)
});
How would you be able to access a private file in a private S3 bucket? I would imagine that there would be alot of annoying authentication steps to go through.
To be able to access a file from a private S3 bucket, you should create a presigned URL for the file.
Usually, this happens on backend, afterwards the URL is passed to the front-end application. Assuming that the back-end has access to the bucket, no additional authentication is needed.