Class: Paperclipdb::AttachmentsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/paperclipdb/attachments_controller.rb

Instance Method Summary collapse

Instance Method Details

#get_attachmentObject



3
4
5
6
7
8
9
10
11
# File 'app/controllers/paperclipdb/attachments_controller.rb', line 3

def get_attachment
  dir_name = '/' + params[:dir_name].join('/') 
  base_name = params[:file_name] + '.' + params[:format]
  attachment = Paperclipdb::Attachment.find(:first, :conditions => [ "base_name = ? AND dir_name = ?", base_name, dir_name ])
  render :text => proc { |response, output|
      response.headers["Content-Type"] = attachment.content_type
      output.write(attachment.file_data)
  }
end