Azalea is aim to make upload file in Phoenix easy. It is still in development. You can check the Example
- Add
azalea
to your list of dependencies inmix.exs
:
def deps do
[{:azalea, "~> 0.0.1"]
end
- Ensure
azalea
is started before your application:
def application do
[applications: [:azalea]]
end
-
Normally we can get a file from
Plug
, it is aPlug.Upload
(see the guide).%Plug.Upload{ content_type: "image/jpg", filename: "demo.jpg", path: "/tmp/file/path"} }
first we should check the file with the checker you define to make sure we get the file we want.
-
Do some work with the file or file data (background). You can define what you want.
-
Save to the target disk you supply, or save to cloud (background).
-
Generate the needed data (with the data we can read from the database and then we can get the file link) and save to database.