2 Antworten
- Neueste
- Die meisten Stimmen
- Die meisten Kommentare
1
You're almost there! What you're not doing is setting the content type when uploading the file to S3. The AWS CLI does this for you automatically (and silently) but you need to set it when using boto3. Luckily that's really easy:
s3 = boto3.client('s3')
s3.put_object(Bucket='bucketNameHere', Key='index.html', Body=bodyOfFileGoesHere, ContentType='text/html')
1
Hi,
You have got an issue with your bucket policy,
'Action': 's3:GetObject',
'Resource': f'{BUCKET_ARN}/*'
With Action with *Object, you must add /* meaning all objects.
beantwortet vor 9 Monaten
Relevanter Inhalt
- AWS OFFICIALAktualisiert vor 3 Jahren
- AWS OFFICIALAktualisiert vor 3 Jahren
- AWS OFFICIALAktualisiert vor 2 Jahren
Already did this but still not working. I updated my question to include the source code.
If you do some debugging - what is the
mime_type
variable set to? Is it actuallytext/html
? You can also check the content type in the AWS Console by looking at the object metadata.