instance method url_for_direct_upload

Ruby on Rails 8.1.4.1

Since v5.2.8.1

Available in: v5.2.8.1 v6.0.6.1 v6.1.7.10 v7.0.10 v7.1.6 v7.2.4 v8.0.5.2 v8.1.4.1 edge

Signature

url_for_direct_upload(key, expires_in:, checksum:, content_length:, custom_metadata: {}, **)

No documentation comment.

Parameters

key req
expires_in keyreq
checksum keyreq
content_length keyreq
custom_metadata key = {}
kwargs keyrest
Source
# File activestorage/lib/active_storage/service/gcs_service.rb, line 92
    def url_for_direct_upload(key, expires_in:, checksum:, content_length:, custom_metadata: {}, **)
      instrument :url, key: key do |payload|
        # V2 signatures bind the Content-Type (empty) and Content-MD5 headers. GCS leaves headers
        # other than x-goog-* out of V2 signatures, so the client sends Cache-Control unsigned.
        args = {
          content_md5: checksum,
          expires: expires_in,
          headers: { "x-goog-content-length-range" => content_length_range(content_length), **custom_metadata_headers(custom_metadata) },
          method: "PUT",
          version: :v2,
        }

        if @config[:iam]
          args[:issuer] = issuer
          args[:signer] = signer
        end

        generated_url = bucket.signed_url(key, **args)

        payload[:url] = generated_url

        generated_url
      end
    end

Defined in activestorage/lib/active_storage/service/gcs_service.rb line 92 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveStorage::Service::GCSService

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close