Sha256: e889d66e3fd91a1fcd331f589c0731cbbece1989429d9e844b3d9ebf3a1e2897

Contents?: true

Size: 824 Bytes

Versions: 13

Compression:

Stored size: 824 Bytes

Contents

class ProtectedMediaController < Spud::ApplicationController

  before_filter :require_user

  def show
    @media = SpudMedia.where(:id => params[:id]).first
    if @media.blank?
      flash[:error] = "The requested file could not be found"
      redirect_to(root_url)
    else
      if Spud::Media.config.paperclip_storage == :s3
        secure_url = @media.attachment.s3_object(params[:style]).url_for(:read, :secure => true, :expires => 10.minutes)
        redirect_to(secure_url.to_s)
      else
        filepath = File.join(Rails.root, @media.attachment.path(params[:style]))
        if !File.exists?(filepath)
          flash[:error] = "The requested file could not be found"
          redirect_to root_path
        else
          send_file(filepath, :disposition => 'inline')
        end
      end
    end
  end

end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
spud_media-1.0.1 app/controllers/protected_media_controller.rb
spud_media-1.0.0 app/controllers/protected_media_controller.rb
spud_media-1.0.0.rc1.1 app/controllers/protected_media_controller.rb
spud_media-1.0.0.rc1 app/controllers/protected_media_controller.rb
tb_media-1.0.1 app/controllers/protected_media_controller.rb
spud_media-0.9.7 app/controllers/protected_media_controller.rb
spud_media-0.9.6 app/controllers/protected_media_controller.rb
tb_media-1.0 app/controllers/protected_media_controller.rb
spud_media-0.9.5 app/controllers/protected_media_controller.rb
spud_media-0.9.4 app/controllers/protected_media_controller.rb
spud_media-0.9.3 app/controllers/protected_media_controller.rb
spud_media-0.9.2 app/controllers/protected_media_controller.rb
spud_media-0.9.1 app/controllers/protected_media_controller.rb