View Source Bonfire.Files (bonfire_umbrella v0.3.6-classic-beta.7)

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 callback is added, forcing you to define what media types are accepted for these types of uploads. (You can also return :all to accept everything).

To use the uploader:

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

Link to this section Summary

Link to this section 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

remote_url(module, media, version \\ nil)

View Source

Return the URL that a local file has.

Link to this function

upload(module, 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

verify_media_type(definition, map)

View Source