[英]static website hosting in s3 using aws-sdk
I am trying to perform static website hosting on s3 that has a simple image file, using aws-sdk from my local ide.我正在尝试使用本地 ide 中的 aws-sdk 在具有简单图像文件的 s3 上执行 static 网站托管。 The code runs without any error and it reflects on my console as well but when i open the endpoint from console it doesn't open the file.
代码运行没有任何错误,它也反映在我的控制台上,但是当我从控制台打开端点时,它不会打开文件。 The file is in the bucket as well and i have enabled public access.
该文件也在存储桶中,我已启用公共访问。 But if i am doing the same through console i mean enabling static website hosting it opens.
但如果我通过控制台做同样的事情,我的意思是启用 static 网站托管它打开。 This is the code...
这是代码...
const aws = require('aws-sdk');
const s3 = new aws.S3();
const fs = require('fs');
const filecon = fs.readFileSync('C:\\Users\\Envy\\Desktop\\murugan.jpeg');
(async function(){
try {
aws.config.setPromisesDependency();
aws.config.update({
region: 'us-east-1'
})
const a1 = await s3.createBucket({Bucket:'ommuruga'}).promise();
const a2 = await s3.upload({Bucket:'ommuruga',Key:'murugan.jpeg',Body:filecon,ACL:'public-read'}).promise();
const a3 = await s3.putBucketWebsite({Bucket:'ommuruga',WebsiteConfiguration:{IndexDocument:{Suffix:'murugan.jpeg'},ErrorDocument:{Key:'Error.html'}}}).promise();
console.log(a3);
}
catch(err){
console.log(`unable to process err: ${err}`);
}
})();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.