Class: CMS::AttachmentsController

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

Instance Method Summary collapse

Instance Method Details

#showObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/cms/attachments_controller.rb', line 5

def show
  name, format = params[:file].sub(/\?.+$/, ''), params[:format]
  file_name = "#{name}.#{format}"
  content_type = Mime::Type.lookup_by_extension(format)

  send_file(
    "#{Rails.root}/private/attachments/#{params[:directory]}/#{file_name}",
    type: content_type,
    filename: file_name,
    disposition: 'inline',
    x_sendfile: !Rails.env.development?,
    stream: true
  )
end