* urls fixed for VRFS-1148
This commit is contained in:
parent
eaecdf7de8
commit
0218ca5ad6
|
|
@ -58,6 +58,16 @@ module JamRuby
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def has_mix?
|
||||||
|
recording.mixes.length > 0 && recording.mixes.first.completed
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_download?(some_user)
|
||||||
|
!ClaimedRecording.find_by_user_id_and_recording_id(some_user.id, recording_id).nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def remove_non_alpha_num(token)
|
def remove_non_alpha_num(token)
|
||||||
token.gsub(/[^0-9A-Za-z]/, '')
|
token.gsub(/[^0-9A-Za-z]/, '')
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -118,20 +118,27 @@ module JamRuby
|
||||||
completed
|
completed
|
||||||
end
|
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 => false})
|
||||||
|
end
|
||||||
|
|
||||||
def sign_url(expiration_time = 120, type='ogg')
|
def sign_url(expiration_time = 120, type='ogg')
|
||||||
|
type ||= 'ogg'
|
||||||
# expire link in 1 minute--the expectation is that a client is immediately following this link
|
# expire link in 1 minute--the expectation is that a client is immediately following this link
|
||||||
if type == 'ogg'
|
if type == 'ogg'
|
||||||
s3_manager.sign_url(self[:ogg_url], {:expires => expiration_time, :response_content_type => 'audio/ogg', :secure => false})
|
resolve_url(:ogg_url, 'audio/ogg', expiration_time)
|
||||||
else
|
else
|
||||||
s3_manager.sign_url(self[:mp3_url], {:expires => expiration_time, :response_content_type => 'audio/mp3', :secure => false})
|
resolve_url(:mp3_url, 'audio/mpeg', expiration_time)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign_put(expiration_time = 3600 * 24, type='ogg')
|
def sign_put(expiration_time = 3600 * 24, type='ogg')
|
||||||
|
type ||= 'ogg'
|
||||||
if type == 'ogg'
|
if type == 'ogg'
|
||||||
s3_manager.sign_url(self[:ogg_url], {:expires => expiration_time, :content_type => 'audio/ogg', :secure => false}, :put)
|
s3_manager.sign_url(self[:ogg_url], {:expires => expiration_time, :content_type => 'audio/ogg', :secure => false}, :put)
|
||||||
else
|
else
|
||||||
s3_manager.sign_url(self[:mp3_url], {:expires => expiration_time, :content_type => 'audio/mp3', :secure => false}, :put)
|
s3_manager.sign_url(self[:mp3_url], {:expires => expiration_time, :content_type => 'audio/mpeg', :secure => false}, :put)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ module JamRuby
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload_sign(content_md5)
|
def upload_sign(content_md5)
|
||||||
s3_manager.upload_sign(self[:url], content_md5, next_part_to_upload, upload_id)
|
s3_manager.upload_sign(url, content_md5, next_part_to_upload, upload_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload_part_complete(part, offset)
|
def upload_part_complete(part, offset)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
class ApiClaimedRecordingsController < ApiController
|
class ApiClaimedRecordingsController < ApiController
|
||||||
|
|
||||||
before_filter :api_signed_in_user
|
before_filter :api_signed_in_user, :except => [ :download ]
|
||||||
before_filter :look_up_claimed_recording, :only => [ :show, :update, :delete ]
|
before_filter :look_up_claimed_recording, :only => [ :show, :update, :delete, :download ]
|
||||||
|
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
|
|
@ -44,7 +44,18 @@ class ApiClaimedRecordingsController < ApiController
|
||||||
#render :json => { :message => "claimed_recording could not be deleted" }, :status => 403
|
#render :json => { :message => "claimed_recording could not be deleted" }, :status => 403
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def download
|
||||||
|
if !@claimed_recording.is_public && @claimed_recording.user_id != current_user.id
|
||||||
|
raise PermissionError, 'this claimed recording is not public'
|
||||||
|
end
|
||||||
|
|
||||||
|
mix = @claimed_recording.recording.mixes.first!
|
||||||
|
|
||||||
|
params[:type] ||= 'ogg'
|
||||||
|
redirect_to mix.sign_url(120, params[:type])
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def look_up_claimed_recording
|
def look_up_claimed_recording
|
||||||
|
|
|
||||||
|
|
@ -26,5 +26,4 @@ class ApiFeedsController < ApiController
|
||||||
|
|
||||||
render "api_feeds/index", :layout => nil
|
render "api_feeds/index", :layout => nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
@ -22,26 +22,10 @@ child(:recording => :recording) {
|
||||||
child(:owner => :owner) {
|
child(:owner => :owner) {
|
||||||
attributes :id, :name, :location, :photo_url
|
attributes :id, :name, :location, :photo_url
|
||||||
}
|
}
|
||||||
|
|
||||||
child(:mixes => :mixes) {
|
|
||||||
attributes :id, :is_completed
|
|
||||||
|
|
||||||
node :mp3_url do |mix|
|
|
||||||
mix[:mp3_url]
|
|
||||||
end
|
|
||||||
|
|
||||||
node :ogg_url do |mix|
|
|
||||||
mix[:ogg_url]
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
child(:recorded_tracks => :recorded_tracks) {
|
child(:recorded_tracks => :recorded_tracks) {
|
||||||
attributes :id, :fully_uploaded, :client_track_id, :client_id, :instrument_id
|
attributes :id, :fully_uploaded, :client_track_id, :client_id, :instrument_id
|
||||||
|
|
||||||
node :url do |recorded_track|
|
|
||||||
recorded_track[:url]
|
|
||||||
end
|
|
||||||
|
|
||||||
child(:user => :user) {
|
child(:user => :user) {
|
||||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :photo_url
|
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :photo_url
|
||||||
}
|
}
|
||||||
|
|
@ -54,4 +38,15 @@ child(:recording => :recording) {
|
||||||
attributes :id, :first_name, :last_name, :photo_url
|
attributes :id, :first_name, :last_name, :photo_url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if :has_mix?
|
||||||
|
node do |claimed_recording|
|
||||||
|
{
|
||||||
|
mix: {
|
||||||
|
mp3_url: claimed_recording_download_url(claimed_recording.id, 'mp3'),
|
||||||
|
ogg_url: claimed_recording_download_url(claimed_recording.id, 'ogg')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -36,25 +36,9 @@ glue :recording do
|
||||||
attributes :id, :name, :location, :photo_url
|
attributes :id, :name, :location, :photo_url
|
||||||
}
|
}
|
||||||
|
|
||||||
child(:mixes => :mixes) {
|
|
||||||
attributes :id, :is_completed
|
|
||||||
|
|
||||||
node :mp3_url do |mix|
|
|
||||||
mix[:mp3_url]
|
|
||||||
end
|
|
||||||
|
|
||||||
node :ogg_url do |mix|
|
|
||||||
mix[:ogg_url]
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
child(:recorded_tracks => :recorded_tracks) {
|
child(:recorded_tracks => :recorded_tracks) {
|
||||||
attributes :id, :fully_uploaded, :client_track_id, :client_id, :instrument_id
|
attributes :id, :fully_uploaded, :client_track_id, :client_id, :instrument_id
|
||||||
|
|
||||||
node :url do |recorded_track|
|
|
||||||
recorded_track[:url]
|
|
||||||
end
|
|
||||||
|
|
||||||
child(:user => :user) {
|
child(:user => :user) {
|
||||||
attributes :id, :first_name, :last_name, :city, :state, :country, :location, :photo_url
|
attributes :id, :first_name, :last_name, :city, :state, :country, :location, :photo_url
|
||||||
}
|
}
|
||||||
|
|
@ -77,6 +61,19 @@ glue :recording do
|
||||||
share_token_url(claimed_recording.share_token.token)
|
share_token_url(claimed_recording.share_token.token)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if :has_mix?
|
||||||
|
node do |claimed_recording|
|
||||||
|
{
|
||||||
|
mix: {
|
||||||
|
mp3_url: claimed_recording_download_url(claimed_recording.id, 'mp3'),
|
||||||
|
ogg_url: claimed_recording_download_url(claimed_recording.id, 'ogg')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,25 +10,9 @@ child(:owner => :owner) {
|
||||||
attributes :id, :name, :location, :photo_url
|
attributes :id, :name, :location, :photo_url
|
||||||
}
|
}
|
||||||
|
|
||||||
child(:mixes => :mixes) {
|
|
||||||
attributes :id, :is_completed
|
|
||||||
|
|
||||||
node :mp3_url do |mix|
|
|
||||||
mix[:mp3_url]
|
|
||||||
end
|
|
||||||
|
|
||||||
node :ogg_url do |mix|
|
|
||||||
mix[:ogg_url]
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
child(:recorded_tracks => :recorded_tracks) {
|
child(:recorded_tracks => :recorded_tracks) {
|
||||||
attributes :id, :fully_uploaded, :client_track_id, :client_id, :instrument_id
|
attributes :id, :fully_uploaded, :client_track_id, :client_id, :instrument_id
|
||||||
|
|
||||||
node :url do |recorded_track|
|
|
||||||
recorded_track[:url]
|
|
||||||
end
|
|
||||||
|
|
||||||
child(:user => :user) {
|
child(:user => :user) {
|
||||||
attributes :id, :first_name, :last_name, :city, :state, :country, :location, :photo_url
|
attributes :id, :first_name, :last_name, :city, :state, :country, :location, :photo_url
|
||||||
}
|
}
|
||||||
|
|
@ -51,4 +35,15 @@ child(:claimed_recordings => :claimed_recordings) {
|
||||||
share_token_url(claimed_recording.share_token.token)
|
share_token_url(claimed_recording.share_token.token)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if :has_mix?
|
||||||
|
node do |claimed_recording|
|
||||||
|
{
|
||||||
|
mix: {
|
||||||
|
mp3_url: claimed_recording_download_url(claimed_recording.id, 'mp3'),
|
||||||
|
ogg_url: claimed_recording_download_url(claimed_recording.id, 'ogg')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -314,11 +314,12 @@ SampleApp::Application.routes.draw do
|
||||||
match '/claimed_recordings/:id' => 'api_claimed_recordings#show', :via => :get
|
match '/claimed_recordings/:id' => 'api_claimed_recordings#show', :via => :get
|
||||||
match '/claimed_recordings/:id' => 'api_claimed_recordings#update', :via => :put
|
match '/claimed_recordings/:id' => 'api_claimed_recordings#update', :via => :put
|
||||||
match '/claimed_recordings/:id' => 'api_claimed_recordings#delete', :via => :delete
|
match '/claimed_recordings/:id' => 'api_claimed_recordings#delete', :via => :delete
|
||||||
|
match '/claimed_recordings/:id/download(/:type)' => 'api_claimed_recordings#download', :via => :get, :as => :claimed_recording_download
|
||||||
|
|
||||||
# Mixes
|
# Mixes
|
||||||
match '/mixes/schedule' => 'api_mixes#schedule', :via => :post
|
match '/mixes/schedule' => 'api_mixes#schedule', :via => :post
|
||||||
match '/mixes/next' => 'api_mixes#next', :via => :get
|
match '/mixes/next' => 'api_mixes#next', :via => :get
|
||||||
match '/mixes/:id/download' => 'api_mixes#download', :via => :get
|
match '/mixes/:id/download(/:type)' => 'api_mixes#download', :via => :get, :as => :mix_download
|
||||||
|
|
||||||
# version check for JamClient
|
# version check for JamClient
|
||||||
match '/versioncheck' => 'artifacts#versioncheck'
|
match '/versioncheck' => 'artifacts#versioncheck'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue