Class: Spree::Api::V3::Store::DigitalsController

Inherits:
Store::BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/v3/store/digitals_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject

GET /api/v3/store/digitals/:token



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/spree/api/v3/store/digitals_controller.rb', line 10

def show
  if @resource.authorize!
    send_data @resource.digital.attachment.download,
              filename: @resource.digital.attachment.filename.to_s,
              type: @resource.digital.attachment.content_type
  else
    render_error(
      code: ERROR_CODES[:digital_link_expired],
      message: 'Download link expired or invalid',
      status: :forbidden
    )
  end
end