Sha256: 41a14158d3d14cdf5e3fc5de44e2459d8432f6e2410010cd299b45d59b8732a9

Contents?: true

Size: 901 Bytes

Versions: 2

Compression:

Stored size: 901 Bytes

Contents

class DocumentsController < CommonDocumentsController
  respond_to :html, :js
  
  SEND_FILE_METHOD = :default

  def create
    super do |format|
      format.all {redirect_to request.referer || home_path}
    end
  end
  
  #TODO: we have to add the mimetype as in videos_controller
  def download
    path = @document.file.path(params[:style])

    head(:bad_request) and return unless File.exist?(path) 

    send_file_options = {
      :filename => @document.file_file_name,
      :type => @document.file_content_type
    }

    # Ask Victor about the rationale of this:
    case SEND_FILE_METHOD
      when :apache then send_file_options[:x_sendfile] = true
      when :nginx then head(:x_accel_redirect => path.gsub(Rails.root, ''))
    end

    send_file(path, send_file_options)
  end

  class << self
    def index_object_type
      [ :Audio, :Video, :Picture, :Document ]
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
social_stream-0.12.0 documents/app/controllers/documents_controller.rb
social_stream-documents-0.4.0 app/controllers/documents_controller.rb