I try to use require() in html. I try to use require in JS but I get the following error Uncaught ReferenceError: require is not defined I wonder how can I use require function on client browser. And there is no way to use require in client browser except requireJS??
const AWS = require('aws-sdk');
const fs = require('fs');
const endpoint = new AWS.Endpoint('https://kr.object.ncloudstorage.com');
const region = 'kr-standard';
const access_key = 'access_key';
const secret_key = 'secret_key';
const S3 = new AWS.S3({
endpoint: endpoint,
region: region,
credentials: {
accessKeyId: access_key,
secretAccessKey: secret_key
}
});
const bucket_name = 'together-image';
const local_file_path = './image.jpg';
(async () => {
let object_name = 'image.jpg';
// create folder
await S3.putObject({
Bucket: bucket_name,
Key: object_name
}).promise();
object_name = 'image.jpg';
// upload file
await S3.putObject({
Bucket: bucket_name,
Key: object_name,
ACL: 'public-read',
Body: fs.createReadStream(local_file_path)
}).promise();
})();
I appreciate with your help in advance
It is not possible unless a module bundler is used. I recommend using aws sdk for browser in https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-started-browser.html