File API
Per-option reference for the file field. For setup and worked examples, see the File guide.
Options are passed to the field declaration in an Avo resource, such as app/avo/resources/user.rb:
field :avatar, as: :file, accept: "image/*", direct_upload: trueShared options such as formatting, visibility, and read-only behavior are documented in Common field options.
Uploads
-> accept
The HTML accept attribute on the file input. It filters the browser's file picker, not the server's upload handling.
field :avatar, as: :file, accept: "image/*"- Type:
Stringornil - Default:
nil - Values: MIME types, wildcard MIME types such as
image/*oraudio/*, or file extensions, including comma-separated lists, as defined by the HTML specification. - Validation: No server-side content-type or size validation is added by this option.
-> direct_upload
Enables Active Storage direct uploads on the file input. Requires the application's Rails direct-upload setup and a storage service configured to accept those uploads.
field :avatar, as: :file, direct_upload: true- Type:
Boolean - Default:
false
Attachment display
-> display_filename
Controls the filename caption below attachment previews on Show and forms, and the image lightbox caption. It does not hide the filename used for non-image, non-audio files on Index.
field :avatar, as: :file, display_filename: false- Type:
Boolean - Default:
true(also when explicitly passednil)
-> lightbox
Enables the in-page lightbox for representable image attachments on Show. Forms retain plain thumbnails. Audio, video, and documents do not open in the image lightbox. The original-file link is included only when the user is authorized to download the attachment.
field :avatar, as: :file, lightbox: false- Type:
Boolean - Default:
true(also when explicitly passednil)
-> link_to_record
Wraps image and audio previews on Index in a link to the record's Show page. It does not affect Show or form previews, or filename-only cells on Index.
field :avatar, as: :file, link_to_record: true- Type:
Boolean - Default:
false