导轨与S3回形针默认图片 [英] rails paperclip default image with S3

查看:128
本文介绍了导轨与S3回形针默认图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用default_url在我的应用程序,但我存储使用S3图像。我不知道我需要什么样的URL就摆在那里,或者如果我要创建一个假的形象只是为了让一切都在那里。

I'm trying to use the default_url in my application but I store the images using S3. I'm not sure what URL I need to put in there or if I have to create a fake image just to get everything up there.

由于我的图片总是通过S3渲染,我不知道如果我只是把一些默认图像在我的公用文件夹它会工作。它似乎没有现在的工作 - 我也只能有一个形象在那里,我知道它有调整。我可以手动将调整大小的图像在那里,但我仍然不知道什么的URL与默认情况下使用。请帮助:)

Since my images always render through S3, I don't know if it would work if I just put in some default images in my public folder. It doesn't seem to be working now - I also only have one image in there, and I know it has to resize. I can manually put the resized images in there but I'm still not sure what URL to use with default. Please help :)

推荐答案

我用回纹针与S3与默认图像在公共文件夹中。它工作正常。我default_url声明是这样的:

I use paperclip with S3 with default images in the public folder. It works fine. My default_url statement looks like this:

:default_url => '/images/:attachment/missing_:style.png'

这意味着,我的执着命名的头像,设置与风格小及大,我必须创建和公共目录把这些图片:

which means that for my attachment named avatar, setup with the styles small and large, I must create and put these images in the public dir:

  • /images/avatar/missing_small.png
  • /images/avatar/missing_large.png

这是<一href="http://rubydoc.info/gems/paperclip/Paperclip/ClassMethods#has_attached_file-instance_method">$p$ptty有据可查的。

供您参考,或在情况下,问题真的是别的地方,这里是我的全曲别针语句:

For your reference, or in the case the problem is really somewhere else, here is my full paperclip statement:

has_attached_file :avatar,
  :styles => { :small => '60x60#', :large => '300x300#' }, :default_style => :large,
  :storage => :s3,
  :default_url => '/images/:attachment/missing_:style.png',
  :path => "users/:id/avatar/:style.:extension",
  :bucket => "bucket name",
  :s3_credentials => {
    :access_key_id => "access key id",
    :secret_access_key => "secret access key"
  },
  :url => ":s3_alias_url", # These two are only required when you alias S3 - e.g. want to use cdn.example.com rather than s3.amazonaws.com
  :s3_host_alias => "my.aws.alias" 

这篇关于导轨与S3回形针默认图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆