Class: Neofiles::FilesController
- Inherits:
-
ActionController::Metal
- Object
- ActionController::Metal
- Neofiles::FilesController
- Includes:
- ActionController::DataStreaming, ActionController::Redirecting, NotFound
- Defined in:
- app/controllers/neofiles/files_controller.rb
Overview
Controller that serves files from the database via single action #show.
If the file requested is an image redirect to Neofiles::ImagesController is made.
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/neofiles/files_controller.rb', line 12 def show file = Neofiles::File.find params[:id] if file.is_a? Neofiles::Image = params.except(:action, :controller, :id) redirect_to neofiles_image_path(), status: 301 and return end send_file_headers!({ filename: CGI::escape(file.filename), type: file.content_type, disposition: 'inline', }) self.status = 200 self.response_body = file.data end |