33 lines
878 B
Ruby
33 lines
878 B
Ruby
require 'aws-sdk'
|
|
|
|
class ApiMusicNotationsController < ApiController
|
|
before_filter :api_signed_in_user
|
|
|
|
respond_to :json
|
|
|
|
def create
|
|
client_id = params[:client_id]
|
|
|
|
if client_id.nil?
|
|
raise JamArgumentError, "client_id must be specified"
|
|
end
|
|
|
|
@music_notations = []
|
|
|
|
params[:files].each do |file|
|
|
music_notation = MusicNotation.create(params[:session_id], file, current_user)
|
|
@music_notations.push music_notation
|
|
end if params[:files]
|
|
|
|
respond_with @music_notations, responder: ApiResponder, :statue => 201
|
|
end
|
|
|
|
def download
|
|
@music_notation = MusicNotation.find(params[:id])
|
|
unless @music_notation.music_session.nil? || @music_notation.music_session.can_join?(current_user, true)
|
|
raise PermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR
|
|
end
|
|
|
|
redirect_to @music_notation.sign_url
|
|
end
|
|
end |