instance method uploaded

Ruby on Rails edge

Since edge

Signature

uploaded(io:)

Called by Attached::Changes::CreateOne to handle the upload workflow for fresh uploads. Processes immediate variants and analyzes from the local io (avoiding a download round-trip), uploads the blob, then runs the :upload callbacks.

For existing blob attachments, the :upload callbacks are run via after_create_commit instead.

Parameters

io keyreq
Source
# File activestorage/app/models/active_storage/attachment.rb, line 71
  def uploaded(io:)
    blob.local_io = io

    process_immediate_variants_from_io(io)
    analyze_blob_from_io(io)

    io.rewind if io.respond_to?(:rewind)
    blob.upload_without_unfurling(io)

    # Persist analysis metadata if the blob was already saved (happens when
    # upload runs in after_commit, after the blob was saved via autosave).
    blob.save! if blob.persisted? && blob.metadata_changed?

    run_upload_callbacks
  ensure
    blob.local_io = nil
  end

Defined in activestorage/app/models/active_storage/attachment.rb line 71 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveStorage::Attachment

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