You are browsing docs for Avo 2: go to Avo 3

Skip to content

Files

WARNING

You must manually require activestorage and image_processing gems in your Gemfile.

ruby
# Active Storage makes it simple to upload and reference files
gem "activestorage"

# High-level image processing wrapper for libvips and ImageMagick/GraphicsMagick
gem "image_processing"

The Files field is similar to File and enables you to upload multiple files at once using the same easy-to-use Active Storage implementation.

ruby
field :documents, as: :files

Options

accept

Instructs the input to accept only a particular file type for that input using the accept option.

ruby
field :cover_video, as: :file, accept: "image/*"

Default

nil

Possible values

image/*, audio/*, doc/*, or any other types from the spec.

direct_upload

License: Pro

If you have large files and don't want to overload the server with uploads, you can use the direct_upload feature, which will upload the file directly to your cloud provider.

ruby
field :cover_video, as: :file, direct_upload: true

Default

false

Possible values

true, false

display_filename

Option that specify if the file should have the caption present or not.

ruby
field :cover_video, as: :file, display_filename: false

Default

true

Possible values

true, false

Authorization

INFO

Please ensure you have the upload_{FIELD_ID}?, delete_{FIELD_ID}?, and download_{FIELD_ID}? methods set on your model's Pundit policy. Otherwise, the input and download/delete buttons will be hidden.

Related:

view_type

Set the default view_type.

Default

grid

Possible values

grid, list

hide_view_type_switcher

Option to hide the view type switcher component.

Default

false

Possible values

true, false