diff --git a/ruby/lib/jam_ruby/lib/s3_manager.rb b/ruby/lib/jam_ruby/lib/s3_manager.rb index fc1be2954..2071cb086 100644 --- a/ruby/lib/jam_ruby/lib/s3_manager.rb +++ b/ruby/lib/jam_ruby/lib/s3_manager.rb @@ -29,7 +29,8 @@ module JamRuby "http#{options[:secure] ? "s" : ""}://s3.amazonaws.com/#{@aws_bucket}/#{filename}" end - # XXX: the client can not support HTTPS atm!!! AGH + # XXX: the client can not support HTTPS atm!!! AGH Change the :url to => https://s3.jamkazam.com when client supports https + # is_native_client check? def upload_sign(filename, content_md5, part_number, upload_id) hdt = http_date_time str_to_sign = "PUT\n#{content_md5}\n#{content_type}\n#{hdt}\n/#{@aws_bucket}/#{filename}?partNumber=#{part_number}&uploadId=#{upload_id}" diff --git a/ruby/lib/jam_ruby/models/mix.rb b/ruby/lib/jam_ruby/models/mix.rb index e88fa063f..410df427f 100644 --- a/ruby/lib/jam_ruby/models/mix.rb +++ b/ruby/lib/jam_ruby/models/mix.rb @@ -305,17 +305,17 @@ module JamRuby end # if the url starts with http, just return it because it's in some other store. Otherwise it's a relative path in s3 and needs be signed - def resolve_url(url_field, mime_type, expiration_time) - self[url_field].start_with?('http') ? self[url_field] : s3_manager.sign_url(self[url_field], {:expires => expiration_time, :response_content_type => mime_type, :secure => true}) + def resolve_url(url_field, mime_type, expiration_time, secure = true) + self[url_field].start_with?('http') ? self[url_field] : s3_manager.sign_url(self[url_field], {:expires => expiration_time, :response_content_type => mime_type, :secure => secure}) end - def sign_url(expiration_time = 120, type='ogg') + def sign_url(expiration_time = 120, type='ogg', secure = true) type ||= 'ogg' # expire link in 1 minute--the expectation is that a client is immediately following this link if type == 'ogg' - resolve_url(:ogg_url, 'audio/ogg', expiration_time) + resolve_url(:ogg_url, 'audio/ogg', expiration_time, secure) else - resolve_url(:mp3_url, 'audio/mpeg', expiration_time) + resolve_url(:mp3_url, 'audio/mpeg', expiration_time, secure) end end diff --git a/ruby/lib/jam_ruby/models/recorded_backing_track.rb b/ruby/lib/jam_ruby/models/recorded_backing_track.rb index 6e927aa40..5a45634c7 100644 --- a/ruby/lib/jam_ruby/models/recorded_backing_track.rb +++ b/ruby/lib/jam_ruby/models/recorded_backing_track.rb @@ -40,8 +40,8 @@ module JamRuby recorded_backing_track end - def sign_url(expiration_time = 120) - s3_manager.sign_url(self[:url], {:expires => expiration_time, :response_content_type => 'audio/ogg', :secure => true}) + def sign_url(expiration_time = 120, secure = true) + s3_manager.sign_url(self[:url], {:expires => expiration_time, :response_content_type => 'audio/ogg', :secure => secure}) end def can_download?(some_user) diff --git a/ruby/lib/jam_ruby/models/recorded_track.rb b/ruby/lib/jam_ruby/models/recorded_track.rb index b94e7535f..7370de36c 100644 --- a/ruby/lib/jam_ruby/models/recorded_track.rb +++ b/ruby/lib/jam_ruby/models/recorded_track.rb @@ -165,8 +165,8 @@ module JamRuby recorded_track.is_skip_mount_uploader = false recorded_track end - def sign_url(expiration_time = 120) - s3_manager.sign_url(self[:url], {:expires => expiration_time, :response_content_type => 'audio/ogg', :secure => true}) + def sign_url(expiration_time = 120, secure = true) + s3_manager.sign_url(self[:url], {:expires => expiration_time, :response_content_type => 'audio/ogg', :secure => secure}) end def upload_start(length, md5) diff --git a/web/app/controllers/api_mixes_controller.rb b/web/app/controllers/api_mixes_controller.rb index af1f9e382..8e0536415 100644 --- a/web/app/controllers/api_mixes_controller.rb +++ b/web/app/controllers/api_mixes_controller.rb @@ -32,7 +32,7 @@ class ApiMixesController < ApiController @mix.valid? if !@mix.errors.any? @mix.save! - redirect_to @mix.sign_url + redirect_to @mix.sign_url(120, 'ogg', !is_native_client?) else render :json => { :message => "download limit surpassed" }, :status => 404 end diff --git a/web/app/controllers/api_recordings_controller.rb b/web/app/controllers/api_recordings_controller.rb index be3b07b26..f33158a83 100644 --- a/web/app/controllers/api_recordings_controller.rb +++ b/web/app/controllers/api_recordings_controller.rb @@ -137,7 +137,7 @@ class ApiRecordingsController < ApiController @recorded_track.valid? if !@recorded_track.errors.any? @recorded_track.save! - redirect_to @recorded_track.sign_url() + redirect_to @recorded_track.sign_url(120, !is_native_client?) else render :json => { :message => "download limit surpassed" }, :status => 404 end @@ -152,7 +152,7 @@ class ApiRecordingsController < ApiController @recorded_backing_track.valid? if !@recorded_backing_track.errors.any? @recorded_backing_track.save! - redirect_to @recorded_backing_track.sign_url + redirect_to @recorded_backing_track.sign_url(120, !is_native_client?) else render :json => { :message => "download limit surpassed" }, :status => 404 end