antikythera v0.4.0 AntikytheraEal.AssetStorage.Behaviour behaviour View Source

Interface to work with storage of asset files.

See AntikytheraEal for common information about pluggable interfaces defined in antikythera.

All callbacks defined in this behaviour are called only within operational mix tasks; they are not used at runtime.

Asset files stored in the storage may be delivered via CDN. It's the callback module's responsibility to properly set headers such as cache-control for each asset file.

Link to this section Summary

Callbacks

Deletes an asset file identified by the given key.

Lists all already-stored asset files for the specified gear.

Lists common key prefixes of all already-stored asset files for all gears.

Uploads the given asset file to the storage.

Link to this section Callbacks

Specs

delete(key :: String.t()) :: :ok

Deletes an asset file identified by the given key.

Specs

Lists all already-stored asset files for the specified gear.

Link to this callback

list_toplevel_prefixes()

View Source

Specs

list_toplevel_prefixes() :: [String.t()]

Lists common key prefixes of all already-stored asset files for all gears.

Based on the key format defined in Antikythera.Asset, the prefixes are expected to be the list of gear names which have already-stored asset files.

Link to this callback

upload(path, key, mime, gzip?)

View Source

Specs

upload(
  path :: Path.t(),
  key :: String.t(),
  mime :: String.t(),
  gzip? :: boolean()
) :: :ok

Uploads the given asset file to the storage.

Parameters:

  • path : File path of the asset file to upload.
  • key : Upload location (typically path part of URL) for the asset file (computed by Antikythera.Asset).
  • mime : MIME type of the asset file.
  • gzip?: Whether gzip compression is beneficial for the asset file.