aboutsummaryrefslogblamecommitdiffstats
path: root/app/controllers/active_storage/direct_uploads_controller.rb
blob: dccd864e8d4f9ffd435a60dc4fef7742f292713c (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                                                                                  
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