Module: Shrine::Plugins::Transloadit2

Defined in:
lib/shrine/plugins/transloadit2.rb

Defined Under Namespace

Classes: Error, ResponseError

Class Method Summary collapse

Class Method Details

.configure(uploader, opts = {}) ⇒ Object

Accepts Transloadit credentials via ‘:auth_key` and `:auth_secret`.

If :cache storage wasn’t assigned, it will be assigned to a URL storage for direct uploads.

If promoting was not yet overriden, it is set to automatically trigger Transloadit processing defined in ‘Shrine#transloadit_process`.

Raises:



28
29
30
31
32
33
34
35
36
# File 'lib/shrine/plugins/transloadit2.rb', line 28

def self.configure(uploader, opts = {})
  uploader.opts[:transloadit_auth_key] = opts.fetch(:auth_key, uploader.opts[:transloadit_auth_key])
  uploader.opts[:transloadit_auth_secret] = opts.fetch(:auth_secret, uploader.opts[:transloadit_auth_secret])

  raise Error, "The :auth_key is required for transloadit plugin" if uploader.opts[:transloadit_auth_key].nil?
  raise Error, "The :auth_secret is required for transloadit plugin" if uploader.opts[:transloadit_auth_secret].nil?

  uploader.opts[:backgrounding_promote] ||= proc { transloadit_process }
end

.load_dependencies(uploader, opts = {}) ⇒ Object

Load the backgrounding plugin to override promoting, and load the versions plugin to automatically save steps.



40
41
42
43
# File 'lib/shrine/plugins/transloadit2.rb', line 40

def self.load_dependencies(uploader, opts = {})
  uploader.plugin :backgrounding
  uploader.plugin :versions
end