Sha256: 493d0437cc8af39c62ac2e874030baad986e76f62d8e5f9e2382c2994a8f4f0d

Contents?: true

Size: 887 Bytes

Versions: 44

Compression:

Stored size: 887 Bytes

Contents

# frozen_string_literal: true

# Creates a new blob on the server side in anticipation of a direct-to-service upload from the client side.
# When the client-side upload is completed, the signed_blob_id can be submitted as part of the form to reference
# the blob that was created up front.
class ActiveStorage::DirectUploadsController < ActiveStorage::BaseController
  def create
    blob = ActiveStorage::Blob.create_before_direct_upload!(blob_args)
    render json: direct_upload_json(blob)
  end

  private
    def blob_args
      params.require(:blob).permit(:filename, :byte_size, :checksum, :content_type, :metadata).to_h.symbolize_keys
    end

    def direct_upload_json(blob)
      blob.as_json(root: false, methods: :signed_id).merge(direct_upload: {
        url: blob.service_url_for_direct_upload,
        headers: blob.service_headers_for_direct_upload
      })
    end
end

Version data entries

44 entries across 44 versions & 5 rubygems

Version Path
activestorage-5.2.8.1 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.8 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.7.1 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.7 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.6.3 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.6.2 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.6.1 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.6 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.4.6 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.5 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.4.5 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.4.4 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.4.3 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-6.0.2.2 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.4.2 app/controllers/active_storage/direct_uploads_controller.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/activestorage-6.0.2.1/app/controllers/active_storage/direct_uploads_controller.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/activestorage-6.0.2.1/app/controllers/active_storage/direct_uploads_controller.rb
activestorage-6.0.2.1 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-5.2.4.1 app/controllers/active_storage/direct_uploads_controller.rb
activestorage-6.0.2 app/controllers/active_storage/direct_uploads_controller.rb