Created
February 24, 2011 13:26
-
-
Save nebolsin/842155 to your computer and use it in GitHub Desktop.
Paperclip extension to work with nginx upload module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Paperclip | |
class Attachment | |
class UploadedPath | |
attr_reader :original_filename, :content_type, :size, :path | |
def initialize(uploaded_file) | |
@original_filename = uploaded_file["name"].downcase | |
@content_type = uploaded_file["content_type"].to_s.strip | |
@file_size = uploaded_file["size"].to_i | |
@path = uploaded_file["path"] | |
`#{Rails.root}/script/chmod #{@path}` | |
end | |
def to_tempfile | |
self | |
end | |
def close | |
end | |
end | |
def assign_with_upload(uploaded_file) | |
uploaded_file = UploadedPath.new(uploaded_file) if uploaded_file.is_a?(Hash) | |
assign_without_upload(uploaded_file) | |
end | |
alias_method_chain :assign, :upload | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment