Files
adamantium/app/actions/media/create.rb

30 lines
604 B
Ruby

module Adamantium
module Actions
module Media
class Create < Action
before :authenticate!
include Deps["commands.media.upload"]
def handle(req, res)
data = req.params[:file]
halt 401 if verify_scope(req: req, scope: :media)
upload.call(file: data) do |m|
m.failure do |v|
res.status = 422
end
m.success do |v|
res.status = 201
res.headers["Location"] = v
res.body = "OK"
end
end
end
end
end
end
end