2 Respuestas
- Más nuevo
- Más votos
- Más comentarios
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.
respondido hace 9 meses
Contenido relevante
- OFICIAL DE AWSActualizada hace 3 años
- OFICIAL DE AWSActualizada hace 3 años
- OFICIAL DE AWSActualizada hace 10 meses
- OFICIAL DE AWSActualizada hace 3 años
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.