scube-server/app/controllers/api/sounds_controller.rb
2015-05-05 02:27:29 +00:00

22 lines
437 B
Ruby

module API
class SoundsController < ApplicationController
skip_before_filter :json_filter!, only: :show
before_action :set_sound, only: :show
def show
send_file @sound.path, type: @sound.mime_type
end
private
def set_sound
@sound = case params[:id]
when /\A\d+\z/ then Sound.find(params[:id])
when /\A\h+\z/ then Sound.find_by_sha256!(params[:id])
end
end
end
end