Asset loading on S3 does not work

I need to upload a css file and js file to S3 and use them as static resources. If I download them over the Internet from the S3 page, it will work. But if I load through a python script, it downloads the files, but I cannot force css, it seems to not work at all.

Here is my python code,

s3 = boto3.resource('s3')
s3.meta.client.upload_file('sample.css', 'mybucket', 'sample_dir/sample.css', {'ACL': 'public-read'})
+4
source share
2 answers

A notable condition is that files downloaded through the console are used correctly by the browser, but files downloaded through the API are not.

AWS/S3 Content-Type: ( CSS , , text/css)... API , .

, , , css, , Content-Type: .

( dev tools/console , ).

+5

.

s3 = boto3.resource('s3')
s3.meta.client.upload_file('sample.css', 'mybucket', 'sample_dir/sample.css', {'ACL': 'public-read','public-read','ContentType': 'text/css'})
+3

Source: https://habr.com/ru/post/1612404/


All Articles