mobilizon.chapril.org-mobil.../lib/mobilizon_web/uploaders/avatar.ex
Thomas Citharel 2f2c538cc9
Add Credo checks and refactor code
Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Make Logger.debug calls lazy

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Add missing @moduledocs

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Refactor according to credo

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Final fixes and add credo to CI

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Closes #52
2019-01-03 15:52:48 +01:00

54 lines
1.4 KiB
Elixir

defmodule MobilizonWeb.Uploaders.Avatar do
@moduledoc """
Handles avatar uploads
"""
use Arc.Definition
# Include ecto support (requires package arc_ecto installed):
# use Arc.Ecto.Definition
@versions [:original]
# To add a thumbnail version:
# @versions [:original, :thumb]
# Override the bucket on a per definition basis:
# def bucket do
# :custom_bucket_name
# end
# Whitelist file extensions:
# def validate({file, _}) do
# ~w(.jpg .jpeg .gif .png) |> Enum.member?(Path.extname(file.file_name))
# end
# Define a thumbnail transformation:
# def transform(:thumb, _) do
# {:convert, "-strip -thumbnail 250x250^ -gravity center -extent 250x250 -format png", :png}
# end
# Override the persisted filenames:
# def filename(version, _) do
# version
# end
# Override the storage directory:
# def storage_dir(version, {file, scope}) do
# "uploads/user/avatars/#{scope.id}"
# end
# Provide a default URL if there hasn't been a file uploaded
# def default_url(version, scope) do
# "/images/avatars/default_#{version}.png"
# end
# Specify custom headers for s3 objects
# Available options are [:cache_control, :content_disposition,
# :content_encoding, :content_length, :content_type,
# :expect, :expires, :storage_class, :website_redirect_location]
#
# def s3_object_headers(version, {file, scope}) do
# [content_type: MIME.from_path(file.file_name)]
# end
end