Skip to content
Petr Mlčoch edited this page Feb 6, 2024 · 4 revisions

There are 3 basic folio file types - that is 3 sql tables which cover most of the required functionality. All of them have a base class and allow (and promote) extending per-project via STI.

Folio::File

Main file type. Folio::Image and Folio::Document STI variants are included in folio core. These file form per-type libraries from which the client can pick images and place them to models having the Folio::HasAttachments concern.

Placement is done via Folio::FilePlacement::Base which also allows STI.

Example use cases:

  • article cover image
  • author image
  • image gallery atom

Folio::PrivateAttachment

Similar to Folio::File, but not creating a public library. Unlike Folio::File, they are directly related to a polymorphic attachmentable without using a placement model.

For some cases, you might want to consider overriding the dragonfly_accessor and setting headers: { "x-amz-acl" => "private" } in the storage_options. That can be done per-class thanks to STI.

Example use cases:

  • attachment of a message in a private chat
  • invoice PDF linked to order

see test/controllers/folio/console/api/private_attachments_controller_test.rb or use concern Folio::HasPrivateAttachments

Folio::SessionAttachment::Base

Used for frontend public uploads. Private x-amz-acl by default.

Example use cases:

  • id card photo/scan of a user trying to register
  • artwork photo of a price request submission