Files
spree_digital/app/controllers/spree/digitals_controller.rb
2011-12-19 18:46:11 +01:00

18 lines
521 B
Ruby

module Spree
class DigitalsController < Spree::BaseController
ssl_required :show
def show
link = DigitalLink.find_by_secret(params[:secret])
if link.present? and link.digital.attachment.present?
attachment = link.digital.attachment
if link.authorize! and File.file?(attachment.path)
send_file attachment.path :filename => attachment.original_filename, :type => attachment.content_type and return
end
end
render :unauthorized
end
end
end