将子域名称提供给aws存储桶

时间:2016-09-23 06:49:27

标签: ruby-on-rails amazon-s3 subdomain spree bucket

我在S3中创建了一个使用URL的图像

https://s3-ap-southeast-1.amazonaws.com/bodyboss-stag/app/public/spree/products/10e/original/16asdf0913_BB_GetYourBossBody_ProductImages_03-2X_eGuide-min.png?1asd474533953

如何使用我的子域名www.images.xyz.com打开此URL,例如

https://images.xyz.com/bodyboss-stag/app/public/spree/products/10e/original/16asdf0913_BB_GetYourBossBody_ProductImages_03-2X_eGuide-min.png?1asd474533953

更新 我点了这个链接https://carltonbale.com/9-hidden-features-of-amazon-s3/

现在我可以使用子域https://images.xyz.com/bodyboss-stag/app/public/spree/products/10e/original/16asdf0913_BB_GetYourBossBody_ProductImages_03-2X_eGuide-min.png?1asd474533953

访问图片了

但是现在我们从s3

支持的图像出现了问题
 Paperclip::Attachment.default_options.merge!(
        s3_credentials: {
            access_key_id: 'XXXXXX',
            secret_access_key: 'XXXXXXXXX',
            bucket: 'images.xyz.com',
        },

        storage:        :s3,
        s3_headers:     { "Cache-Control" => "max-age=31557600" },
        s3_protocol:    "https",
        s3_region: 'Singapor',
        s3_host_name:   's3-ap-southeast-1.amazonaws.com',
        bucket:         'images.xyz.com',
    )

我尝试将 s3_host_name 更改为images.xyz.com,但它给了我错误

Cany现在有人帮助设置这个,以便我可以生成像images.xyz.com/rest_of_the_path

这样的网址

1 个答案:

答案 0 :(得分:0)

我认为你可能错过了Paperclip中的URL设置。

Paperclip::Attachment.default_options.merge!(
  s3_credentials: {
    access_key_id: 'XXXXXX',
    secret_access_key: 'XXXXXXXXX',
    bucket: 'images.xyz.com',
  },

  storage:        :s3,
  s3_headers:     { "Cache-Control" => "max-age=31557600" },
  s3_protocol:    "https",
  s3_region: 'Singapor',
  s3_host_name:   's3-ap-southeast-1.amazonaws.com',
  bucket:         'images.xyz.com',
  url:            'images.xyz.com'                           
}