Wednesday 9 November 2011

Paperclip fog storage : content_type fix

Add this initializer to set the correct content_type when you use fog storage with paperclip - version <= '2.3.12'

# patch from https://github.com/lisausa/paperclip/commit/e03007da2cedd7c32dbd5d1601d215897e00bc51
module Paperclip
  module Storage
    module Fog

      def flush_writes
        for style, file in @queued_for_write do
          log("saving #{path(style)}")
          directory.files.create(
            :body         => file,
            :key          => path(style),
            :public       => @fog_public,
            :content_type => file.content_type.to_s.strip
          )
        end
        @queued_for_write = {}
      end

    end
  end
end
 Done.

No comments:

Post a Comment