# Dropkick

Dropkick is a highly experimental library that provides easy to use uploads for the Elixir/ Phoenix ecosystem.  
This is a opinionated library focused on developer ergonomics that you can use to provide file uploads in any Phoenix project.

## Installation

def deps do
    {:dropkick, ">= 0.0.0"}

## Usage

### Setup

- Add a map column to your database table: `add(:avatar, :map)` 
- Add a `Dropkick.File` field to your ecto schema: `field(:avatar, Dropkick.File)`

### Configuration

Add the following configuration to your `config.exs`:

config :dropkick,
  repo: MyAppRepo,
  storage: Dropkick.Storage.Disk,
  folder: "uploads"

### Uploader

Define an uplodader for your application:

defmodule MyApp.Uploader do
  use Dropkick.Uploader

  # Defines where to store the user avatar through pattern matching
  def storage_prefix({user, :avatar}), do: "avatars/#{}"

  # You can also implement a list of callbacks that allow you to 
  # customize what happens in your upload pipeline
  # def process(file, _scope), do: {:ok, file}
  # def before_store(file, _scope), do: {:ok, file}
  # def after_store(file, _scope), do: {:ok, file}
  # def before_delete(file, _scope), do: {:ok, file}
  # def after_delete(file, _scope), do: {:ok, file}

### Save the files

import Dropkick.Context

def create_user(user, attrs) do
  |> User.changeset(attrs)
  |> insert_with_files(MyApp.Uploader)

def update_user(user, attrs) do
  |> User.changeset(attrs)
  |> update_with_files(MyApp.Uploader)

## Missing bits

- Add integration for file transformations
- Add integration with [Briefly]( to make transformation/ cleanup of temporary files easier.
- Support other types of storages (S3, Azure, etc)
- Add strategy to allow cleaning up old files after update
- Improve documentation and examples for modules and functions
- Add examples of using libraries for processing files: 
  - [`image`](
  - [`ex_optimizer`](
  - [`mogrify`](