回形针图像旋转不适用于 s3

paperclip image rotation not working with s3

感谢关注,

我正在尝试旋转已上传到 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

好的,我找到解决方法了,我不小心忘了设置URL