我的AWS Bucket中的图像未显示在我的网站上 [英] Images from my AWS Bucket not showing on my website
本文介绍了我的AWS Bucket中的图像未显示在我的网站上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在我的Django项目中实现了AWS S3存储.因此,我只是将所有静态图像上传到了存储桶中.但是,它没有显示在我的网站上.我的图片HTML是模板的标准Django语法:
I've implemented AWS S3 storage to my Django project. So I just uploaded all my static images to my bucket. However it is not showing up on my site. My HTML for the images are the standard Django syntax for template:
<img src="{% static 'images/settingsIcon.png' %}">
img
src
似乎指向正确的URL(我的存储桶中的图像):
The img
src
appears to point to the correct URL (the image in my bucket):
但是图像仍然不起作用.知道为什么吗?
however the image still doesn't work. Any idea why?
推荐答案
您需要更改上传文件'ContentType'=>'image/jpeg'的Content-Type. 而且,您还需要关闭阻止公共访问".
You need to change Content-Type of the uploaded file 'ContentType' =>'image/jpeg'. And, also you need to turn off Block public access.
const uploadFile = new aws.S3.ManagedUpload({
params: {
...uploadParams,
ContentType: 'image/jpeg',
Key: file.name,
Body: fileUploadStream,
},
});
这篇关于我的AWS Bucket中的图像未显示在我的网站上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文