✓ Solved
How to convert a bucket into the static website?
Hey I just followed these steps but somehow the end url is not rendering the index html instead it just download the file.
cb = client.create_bucket(Bucket=blog_name, ACL="public-read")
fileobj_response = client.upload_fileobj(
io.BytesIO(index.encode()), Bucket=blog_name, Key="index.html"
)
object_acl_response = client.put_object_acl(
ACL="public-read", Bucket=blog_name, Key="index.html"
)
And then I visited this page blog_name.ap-south-1.linodeobjects.com
and also blog_name.website-ap-south-1.linodeobjects.com
but when I entered these URL into the browser URL field it just download the website instead of rendering it.
Can someone explain what is going on here?
1 Reply
✓ Best Answer
I am closing this issue because I found the answer. The trick is to set the content type to the file when it's uploading.
client.upload_fileobj(
io.BytesIO(index.encode()),
Bucket=name,
Key="index.html",
ExtraArgs={"ContentType": "application/json", "ACL": "public-read"},
)