uploads to s3
This commit is contained in:
parent
f6d957a25c
commit
8aa6b5ac14
1
Gemfile
1
Gemfile
@ -31,6 +31,7 @@ gem 'asset_sync'
|
||||
gem 'angularjs-rails'
|
||||
gem 'undertaker' # Thanks Brian
|
||||
gem 'httparty'
|
||||
gem 'aws-sdk'
|
||||
|
||||
group :development do
|
||||
gem 'foreman'
|
||||
|
@ -60,6 +60,9 @@ GEM
|
||||
activemodel
|
||||
fog (>= 1.8.0)
|
||||
awesome_print (1.2.0)
|
||||
aws-sdk (1.41.0)
|
||||
json (~> 1.4)
|
||||
nokogiri (>= 1.4.4)
|
||||
bcrypt (3.1.7)
|
||||
better_errors (1.1.0)
|
||||
coderay (>= 1.0.0)
|
||||
@ -303,6 +306,7 @@ DEPENDENCIES
|
||||
annotate!
|
||||
asset_sync
|
||||
awesome_print
|
||||
aws-sdk
|
||||
better_errors
|
||||
binding_of_caller
|
||||
bootstrap-sass (< 3.1)
|
||||
|
@ -3,18 +3,21 @@ require 'tempfile'
|
||||
|
||||
class AmazonCopy
|
||||
def download_video videolisting
|
||||
|
||||
file = Tempfile.new ["video_",".mp4"], "#{Rails.root}/tmp"
|
||||
begin
|
||||
file.write HTTParty.get(videolisting.get_video_url).parsed_response.force_encoding("utf-8")
|
||||
file.flush
|
||||
puts "File #{videolisting.videocode} downloaded."
|
||||
|
||||
s3 = AWS::S3.new
|
||||
obj = s3.buckets['digitalmarketingvideos'].objects["#{videolisting.videocode}.mp4"]
|
||||
obj.write(file)
|
||||
puts "File #{videolisting.videocode} uploaded."
|
||||
|
||||
ensure
|
||||
file.close
|
||||
file.unlink
|
||||
end
|
||||
|
||||
|
||||
file.unlink
|
||||
|
||||
end
|
||||
handle_asynchronously :download_video
|
||||
end
|
Loading…
Reference in New Issue
Block a user