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 'angularjs-rails'
|
||||||
gem 'undertaker' # Thanks Brian
|
gem 'undertaker' # Thanks Brian
|
||||||
gem 'httparty'
|
gem 'httparty'
|
||||||
|
gem 'aws-sdk'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'foreman'
|
gem 'foreman'
|
||||||
|
@ -60,6 +60,9 @@ GEM
|
|||||||
activemodel
|
activemodel
|
||||||
fog (>= 1.8.0)
|
fog (>= 1.8.0)
|
||||||
awesome_print (1.2.0)
|
awesome_print (1.2.0)
|
||||||
|
aws-sdk (1.41.0)
|
||||||
|
json (~> 1.4)
|
||||||
|
nokogiri (>= 1.4.4)
|
||||||
bcrypt (3.1.7)
|
bcrypt (3.1.7)
|
||||||
better_errors (1.1.0)
|
better_errors (1.1.0)
|
||||||
coderay (>= 1.0.0)
|
coderay (>= 1.0.0)
|
||||||
@ -303,6 +306,7 @@ DEPENDENCIES
|
|||||||
annotate!
|
annotate!
|
||||||
asset_sync
|
asset_sync
|
||||||
awesome_print
|
awesome_print
|
||||||
|
aws-sdk
|
||||||
better_errors
|
better_errors
|
||||||
binding_of_caller
|
binding_of_caller
|
||||||
bootstrap-sass (< 3.1)
|
bootstrap-sass (< 3.1)
|
||||||
|
@ -3,18 +3,21 @@ require 'tempfile'
|
|||||||
|
|
||||||
class AmazonCopy
|
class AmazonCopy
|
||||||
def download_video videolisting
|
def download_video videolisting
|
||||||
|
|
||||||
file = Tempfile.new ["video_",".mp4"], "#{Rails.root}/tmp"
|
file = Tempfile.new ["video_",".mp4"], "#{Rails.root}/tmp"
|
||||||
begin
|
begin
|
||||||
file.write HTTParty.get(videolisting.get_video_url).parsed_response.force_encoding("utf-8")
|
file.write HTTParty.get(videolisting.get_video_url).parsed_response.force_encoding("utf-8")
|
||||||
file.flush
|
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
|
ensure
|
||||||
file.close
|
file.close
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
file.unlink
|
file.unlink
|
||||||
|
end
|
||||||
end
|
end
|
||||||
handle_asynchronously :download_video
|
handle_asynchronously :download_video
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user