37 lines
989 B
Ruby
37 lines
989 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_notation = MusicNotation.new
|
|
@music_notation.client_id = client_id
|
|
@music_notation.file_url = params[:file]
|
|
@music_notation.user = current_user
|
|
@music_notation.save
|
|
|
|
if @music_notation.errors.any?
|
|
response.status = :unprocessable_entity
|
|
respond_with @music_notation
|
|
else
|
|
respond_with @music_notation, responder: ApiResponder, :statue => 201
|
|
end
|
|
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 |