Sha256: e644ead40ab4393667aeb3cf96dc5fc77641819298a09e61adc8dd77c8743281
Contents?: true
Size: 810 Bytes
Versions: 14
Compression:
Stored size: 810 Bytes
Contents
# Controller that serves files from the database via single action #show. # # If the file requested is an image redirect to Neofiles::ImagesController is made. # class Neofiles::FilesController < ActionController::Metal include ActionController::DataStreaming include ActionController::Redirecting include Rails.application.routes.url_helpers include Neofiles::NotFound def show file = Neofiles::File.find params[:id] if file.is_a? Neofiles::Image options = params.except(:action, :controller, :id) redirect_to neofiles_image_path(options), 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 end
Version data entries
14 entries across 14 versions & 1 rubygems