小编Ram*_*mar的帖子

background-image:url无法用于Amazon S3图像

我想要的是

我正在尝试为class设置背景图像,该图像存储在Amazon s3上,我正在通过Rails上的回形针对象访问该图像

CSS类

.user-area{
    background-image:url('<%=@user.background_image.expiring_url %>');
    background-repeat:no-repeat;
    width:1025px !important;
    margin-top:100px !important;
}
Run Code Online (Sandbox Code Playgroud)

放在浏览器上

.user-area{
    background-image:url('https://xyz-customers.s3.amazonaws.com/photos/7/superbackground.jpg?AWSAccessKeyId=xxxxxxxxxxxxx&amp;Expires=1402511741&amp;Signature=xxxxxxxxxxxxxxxx');
    background-repeat:no-repeat;
    width:1025px !important;
    margin-top:100px !important;
}
Run Code Online (Sandbox Code Playgroud)

问题

该图像在浏览器上不可见,但是当我访问Amazon s3 url(在css类上生成)时,我可以查看该图像。

浏览器还会为此文件抛出403错误, is a Failed to load resource: the server responded with a status of 403 (Forbidden)

html css ruby-on-rails amazon-s3 amazon-web-services

2
推荐指数
1
解决办法
3707
查看次数