class

ActiveStorage::Blob

Inherits ActiveRecord::Base < Reference < Object

STI subclasses inherit the table name (explicit override or convention) from their model superclass (one level; deeper STI needs an explicit set_table_name). Intermediate abstract bases (ApplicationRecord) are not models — walk past them. STI shape: a non-abstract registered model superclass marks the class as single-table-inherited (abstract intermediates like ApplicationRecord do not).

Constants

KEY_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
VARIABLE_CONTENT_TYPES = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/webp", "image/tiff", "image/bmp", "image/avif"] of ::String

Constructors

create_and_upload!(io : String, filename : String, content_type : String | Nil = nil) : self
Source
create_before_direct_upload!(filename : String, byte_size : Int64, checksum : String, content_type : String | Nil = nil, key : String | Nil = nil) : self

A saved blob WITHOUT a file on the service (the file follows via a client-side direct upload to service_url_for_direct_upload).

Source
find_signed!(signed_id : String, purpose : String = "blob_id") : self

Неверная подпись/purpose → MessageVerifier::InvalidSignature (как в Rails); верная подпись без записи → RecordNotFound.

Source

Class methods

find_signed(signed_id : String, purpose : String = "blob_id") : self | Nil
Source
generate_key
Source

Instance methods

audio?
Source
before_save__cb_0

Rails: before_save :identify, if: :unidentified? — a blob saved without a declared content type gets one from its magic bytes (Marcel::MimeType.for(download, name:, declared_type:)).

Source
download
Source
identified?

The gem has no identified column either: presence of the content_type column is the flag.

Source
identify
Source
image?
Source
purge
Source
representable?

previewable? needs previewers (ffmpeg/poppler) — P2; a blob is representable in the port when it is variable.

Source
service_headers_for_direct_upload
Source
service_url_for_direct_upload(expires_in : Int32 = ActiveStorage.service_urls_expire_in) : String

URL the client PUTs the file to (presigned for cloud services, verifier-tokened for Disk).

Source
signed_id

Signed reference safe to expose client-side (direct-upload round trip: the browser submits this instead of the file).

Source
text?
Source
unidentified?
Source
url(expires_in : Int32 = 300) : String
Source
variable?
Source
variant
Source
video?
Source