Class: ActionController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/paperzip.rb

Instance Method Summary collapse

Instance Method Details

#paperzip(attachments = [], name = 'file', style = :original) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/paperzip.rb', line 2

def paperzip( attachments= [], name= 'file', style= :original )
  # set headers
  response.headers["Content-Disposition"] = "attachment; filename=#{name}.zip"
  response.headers["X-Archive-Files"] = "zip"

  # Generate file list
  render :text => attachments.collect{|a|
    [
      Zlib.crc32(File.read(a.path(style)),0).to_s(16), 
      File.size(a.path(style)), a.url(style,false), 
      a.original_filename.gsub(/ /,'_')].join(' ')
  }.join("\r\n")+"\r\n"
end