Class: UploadJuicer::Upload
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- UploadJuicer::Upload
- Defined in:
- app/models/upload_juicer/upload.rb
Instance Method Summary collapse
-
#juice_upload(outputs) ⇒ Object
The outputs var goes from this: { :avatar => { :size => ‘40x40>’ } } to this: [ { :label => ‘avatar’, :size => ‘40x40>’, :url => s3_url(‘avatar’) } ].
- #s3_path(style = nil) ⇒ Object
- #s3_url(style = nil) ⇒ Object
- #url(style = nil) ⇒ Object
Instance Method Details
#juice_upload(outputs) ⇒ Object
The outputs var goes from this:
{ :avatar => { :size => '40x40>' } }
to this:
[ { :label => 'avatar', :size => '40x40>', :url => s3_url('avatar') } ]
26 27 28 29 |
# File 'app/models/upload_juicer/upload.rb', line 26 def juice_upload(outputs) output_array = outputs.collect {|style, opts| { :label => style.to_s, :url => s3_url(style) }.merge(opts) } UploadJuicer::Job.submit(UploadJuicer::Config.api_key, s3_url, output_array) end |
#s3_path(style = nil) ⇒ Object
16 17 18 19 20 |
# File 'app/models/upload_juicer/upload.rb', line 16 def s3_path(style = nil) style = style.to_s style << '/' unless style.blank? || style.ends_with?('/') "#{key}/#{style}#{file_name}" end |
#s3_url(style = nil) ⇒ Object
12 13 14 |
# File 'app/models/upload_juicer/upload.rb', line 12 def s3_url(style = nil) "s3://#{UploadJuicer::Config.s3['bucket']}/#{s3_path(style)}" end |
#url(style = nil) ⇒ Object
8 9 10 |
# File 'app/models/upload_juicer/upload.rb', line 8 def url(style = nil) "http://#{UploadJuicer::Config.s3['bucket']}.s3.amazonaws.com/#{s3_path(style)}" end |