Class: Spree::DigitalAssetProvider::File

Inherits:
Base
  • Object
show all
Defined in:
app/models/spree/digital_asset_provider/file.rb

Overview

The default provider: an uploaded file on private storage. Reproduces the pre-wave-6 download behaviour — a short-lived signed storage URL the customer is redirected to — now expressed through the provider seam.

Constant Summary

Constants inherited from Base

Base::SETTING_TYPES

Instance Attribute Summary

Attributes inherited from Base

#digital_asset

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, own_settings, provider_name, setting, settings_schema

Methods included from ApiTyped

#api_type, api_type_for, #api_typed_family, class_name_for, find, registered_class

Constructor Details

This class inherits a constructor from Spree::DigitalAssetProvider::Base

Class Method Details

.requires_attachment? ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'app/models/spree/digital_asset_provider/file.rb', line 7

def self.requires_attachment?
  true
end

Instance Method Details

#deliver(_digital_link, expires_in:) ⇒ Object



11
12
13
14
15
16
17
# File 'app/models/spree/digital_asset_provider/file.rb', line 11

def deliver(_digital_link, expires_in:)
  return unless digital_asset.attachment.attached?

  Spree::DigitalDelivery.new(
    redirect_url: digital_asset.attachment.url(expires_in: expires_in, disposition: :attachment)
  )
end