I am trying to upload the file on Digital Ocean server from the backend (nodeJs) using s3. File uploaded successfully but I want that file only access by my frontend (React).
The code of uploading a file from nodeJs like this -
const AWS = require('aws-sdk')
// Configure client for use with Spaces
const spacesEndpoint = new AWS.Endpoint('nyc3.digitaloceanspaces.com');
const s3 = new AWS.S3({
endpoint: spacesEndpoint,
accessKeyId: 'ACCESS_KEY',
secretAccessKey: 'SECRET_KEY'
});
// Add a file to a Space
var params = {
Body: "The contents of the file",
Bucket: "my-new-space-with-a-unique-name",
Key: "file.ext",
ACL: 'public-read'
};
s3.upload(params, function (error, data) {
if (error) {
return reject(error);
}
return resolve(data.Location);
});
I have no idea how to set the correct permissions on the s3 bucket. I am new to the digital ocean so give steps from the beginning.