【问题标题】:paperclip image rotation not working with s3回形针图像旋转不适用于 s3
【发布时间】:2019-07-18 16:34:52
【问题描述】:

感谢关注,

我正在尝试旋转上传到 s3 的图像。这是我在 app/models/pic.rb 中实现的

def rotate!(degrees)
  self.rotation += degrees.to_i
  image.reprocess!
  image.save
  save!
end

问题:当我在旋转后保存图像时,它保存在默认路径而不是原始 s3 图像路径中。 IE。它保存在 s3 但在错误的文件夹中。

这里是回形针配置

def set_default_attachment_options
  Paperclip::Attachment.default_options.merge!(
    # Stripping EXIF data unless WW model gallery.
    # Ensuring RGB at 72dpi. Oversampling for smoother resizing. Applying unsharp mask.
    :convert_options => {
      :all       => lambda { |i| '-strip' unless i.respond_to?(:ww_model?) && i.ww_model? },
      :max       => '-colorspace RGB -density 72 -quality 85 -resize 200% -resize 50% -unsharp 1x1+.5+.1',
      :page      => '-colorspace RGB -density 72 -quality 85 -resize 200% -resize 50% -unsharp 1x1+.5+.1',
      :croppable => '-colorspace RGB -density 72 -quality 85',
      :thumb     => '-colorspace RGB -density 72 -quality 85',
    },
    :default_url     => '/assets/pending/:class/:attachment/:style.png',
    :hash_secret     => hash_secret,
    :path            => s3? ? attachment_url_format : attachment_path_format,
    :s3_credentials  => s3_credentials_yaml_path, # DISCUSS: do we need that or does aws-sdk give us that for free?
    :s3_headers      => { 'Cache-Control' => 'public', 'Expires' => 1.year.from_now.httpdate },
    :s3_host_alias   => cdn_host,
    :s3_protocol     => "https", # this makes http:// and https:// dynamic.
    :storage         => s3? ? :s3 : :filesystem,
    :url             => s3? ? ':s3_alias_url' : attachment_url_format,
    :use_timestamp   => false,
    :whiny           => !Rails.env.production?
  )
end

【问题讨论】:

    标签: amazon-web-services ruby-on-rails-3 amazon-s3 imagemagick paperclip


    【解决方案1】:

    好的,我找到了解决办法,我错误地忘记设置网址了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-07
      • 1970-01-01
      • 2011-07-01
      • 2017-07-20
      相关资源
      最近更新 更多