1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/app/controllers/active_storage/direct_uploads_controller.rb
David Heinemeier Hansson 6c2cef21ce Fix-up variants controller
2017-07-20 17:34:32 -05:00

11 lines
398 B
Ruby

class ActiveStorage::DirectUploadsController < ActionController::Base
def create
blob = ActiveStorage::Blob.create_before_direct_upload!(blob_args)
render json: { url: blob.url_for_direct_upload, sgid: blob.to_sgid.to_param }
end
private
def blob_args
params.require(:blob).permit(:filename, :byte_size, :checksum, :content_type, :metadata).to_h.symbolize_keys
end
end