View Source Bonfire.Files (bonfire_umbrella v0.9.10-cooperation-beta.62)

This module contains general functions for handling files, and also an Ecto schema which is a multimixin for storing one or more media attached to a Pointable object.

An uploader definition must be provided for each new upload, or will be automatically chosen based on the file type.

A few definitions exist as defaults inside of this namespace, but you can also define your own - a Bonfire.Files.Definition is an extension of Waffle.Definition, however the allowed_media_types/0 and max_file_size/0 callback are added, with which you need to define what media types are accepted for these types of uploads. (You can also return :all to accept all media types).

To use the uploader:

iex> {:ok, media} = Bonfire.Files.upload(MyUploader, creator_or_context, %{path: "./150.png"})
iex> media.media_type
"image/png"
iex> Bonfire.Files.remote_url(MyUploader, media)
"/uploads/my/01F3AY6JV30G06BY4DR9BTW5EH"

Summary

Functions

Link to this function

ap_publish_activity(medias)

View Source
Link to this function

ap_receive_attachments(creator, attachments)

View Source
Link to this function

data_url(content, mime_type)

View Source
Link to this function

file_extension_only(path)

View Source
Link to this function

normalise_size(size, default \\ 8)

View Source
Link to this function

remote_url(module \\ nil, media, version \\ :default)

View Source

Return the URL that a local file has.

Link to this function

upload(module, creator_or_context, file, attrs \\ %{}, opts \\ [])

View Source

Attempt to store a file, returning an upload, for any parent item that participates in the meta abstraction, providing the user/context of the upload.

Link to this function

validate(other, allowed_media_types, max_file_size)

View Source