http for natve client
This commit is contained in:
parent
76ac0588a3
commit
35bbecc62e
|
|
@ -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}"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue