class Transloadit::Rails::Engine
Constants
- CONFIG_PATH
Attributes
application[RW]
Public Class Methods
configuration()
click to toggle source
Returns the configuration object (read from the YAML config file)
# File lib/transloadit/rails/engine.rb, line 30 def self.configuration if !@configuration || ::Rails.env.development? path = self.application.root.join(CONFIG_PATH) erb = ERB.new(path.read) erb.filename = path.to_s @configuration = YAML.load(erb.result) end if @configuration.keys.include?(::Rails.env) @configuration = @configuration[::Rails.env] end @configuration end
sign(params)
click to toggle source
Signs a request to the Transloadit
API.
# File lib/transloadit/rails/engine.rb, line 85 def self.sign(params) Transloadit::Request.send :_hmac, self.transloadit.secret, params end
template(name, options = {})
click to toggle source
Creates an assembly for the named template.
name - The String or Symbol template name. options - The Hash options used to refine the Assembly (default: {}):
:steps - The Hash with Assembly Steps (optional). :max_size - The Integer maximum size an upload can have in bytes (optional).
# File lib/transloadit/rails/engine.rb, line 66 def self.template(name, options = {}) transloadit = self.transloadit( :max_size => options.delete(:max_size) ) template = self.configuration['templates'].try(:fetch, name.to_s) assembly_options = case template when String { :template_id => template }.merge(options) when Hash template.merge(options) end transloadit.assembly(assembly_options) end
transloadit(options = {})
click to toggle source
Returns the Transloadit
authentication object.
options - The Hash options used to refine the auth params (default: {}):
:max_size - The Integer maximum size an upload can have in bytes (optional).
# File lib/transloadit/rails/engine.rb, line 50 def self.transloadit(options = {}) Transloadit.new( :key => self.configuration['auth']['key'], :secret => self.configuration['auth']['secret'], :duration => self.configuration['auth']['duration'], :max_size => options[:max_size] || self.configuration['auth']['max_size'] ) end