Sha256: 202c7adbb4ec238ff111497bf0c1c0cca80f28840e4242732b188fb2b83007d7
Contents?: true
Size: 885 Bytes
Versions: 12
Compression:
Stored size: 885 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.expect(blob: [: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
12 entries across 12 versions & 2 rubygems