Class: ElFinder2::Command::File

Inherits:
Base
  • Object
show all
Defined in:
lib/el_finder2/command/resize.rb

Overview

Output file into browser. This command applies to download and preview actions.

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from HashUtils

#from_base64url, #to_base64url, #to_path

Constructor Details

This class inherits a constructor from ElFinder2::Command::Base

Instance Method Details

#executeObject

May need to set Content-Disposition, Content-Location and Content-Transfer-Encoding. Content-Disposition should have ‘inline’ for preview action or ‘attachments’ for download.



9
10
11
12
13
14
15
16
# File 'lib/el_finder2/command/resize.rb', line 9

def execute
  if @download
    data = Paperclip.io_adapters.for(@file.content)
    send_data(data.read, filename: @file.name, type: @file.content_type)
  else
    redirect_to @file.content.url
  end
end