Files API
Per-option reference for the :files field. For setup and worked examples, see the Files guide.
Options are passed to the field declaration in an Avo resource, such as app/avo/resources/project.rb:
field :documents, as: :filesThese options are specific to multiple attachments. See Common field options for the options shared by all fields.
Upload input
-> accept
The file input's HTML accept attribute. It accepts MIME types, file extensions, and comma-separated combinations as described in the HTML specification.
field :documents, as: :files, accept: "image/*,application/pdf"- Type:
Stringornil - Default:
nil(no file-type filter) - Validation: Not validated by Avo; passed to the file input.
WARNING
accept filters the browser's file picker; it does not enforce attachment content types on the server.
-> direct_upload
Enables Active Storage direct uploads for the multiple-file input. Requires a configured Active Storage direct-upload service.
field :documents, as: :files, direct_upload: true- Type:
Boolean - Default:
false
Attachment layout
-> view_type
The initial attachment layout on show and edit pages. A valid view_type request parameter takes precedence over this setting.
field :documents, as: :files, view_type: :list| Value | Behavior |
|---|---|
:grid | Thumbnail tiles with previews for images, audio, and video. |
:list | File rows with filenames, sizes, and attachment controls. |
- Type:
Symbol - Default:
:grid - Values:
:grid,:list - Validation: No declaration-time validation. An unsupported layout can raise
NameErrorwhen the attachment viewer resolves its component.
-> hide_view_type_switcher
Hides the grid/list switcher above the attachments. This does not prevent a valid view_type request parameter from selecting a layout.
field :documents, as: :files, hide_view_type_switcher: true- Type:
Booleanornil - Default:
nil(switcher visible)
-> display_filename
Controls filename captions beneath grid previews and in the lightbox. List rows always display their filenames.
field :documents, as: :files, display_filename: false- Type:
Boolean - Default:
true(also used when explicitly set tonil)
Image preview
-> lightbox
Enables the in-page image lightbox on the show page for representable image attachments. Edit-page thumbnails are not lightbox triggers. Audio, video, and documents retain their existing players and controls; the original-file link in the lightbox respects download authorization.
field :documents, as: :files, lightbox: false- Type:
Boolean - Default:
true(also used when explicitly set tonil)