Class: InboxItems::MoveFileUploadToS3
- Inherits:
-
Object
- Object
- InboxItems::MoveFileUploadToS3
- Defined in:
- app/services/move_file_upload_to_s3.rb
Class Method Summary collapse
Class Method Details
.call(file_upload) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/services/move_file_upload_to_s3.rb', line 5 def self.call(file_upload) path = "file_uploads/#{file_upload.id}_#{file_upload.created_at.to_i}/#{file_upload.filename}" s3file = Amazon.put({file: file_upload.local_file, path: path, bucket: Settings.s3_bucket}) if s3file url = s3file.url_for(:read, {secure: false}).to_s.split('?')[0] file_upload.update_attributes(url: url, path: path) File.unlink(file_upload.local_file) end end |