ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - doomspork/artifact: File upload and on-the-fly processing for Elixir
File upload and on-the-fly processing for Elixir. Contribute to doomspork/artifact development by creating an account on GitHub.
Visit Site

GitHub - doomspork/artifact: File upload and on-the-fly processing for Elixir

GitHub - doomspork/artifact: File upload and on-the-fly processing for Elixir

Artifact

File upload and on-the-fly processing for Elixir

Build Status Hex Version License

Artifact is under active development, join the fun!

Installation

Add artifact to your list of dependencies in mix.exs:

def deps do
  [{:artifact, "~> 0.4"}]
end

Next, add :artifact to your list of applications:

def application do
  [applications: [:artifact]]
end

Since artifact relies on external processes for transformations, it is recommended that you install the goon middleware. To install, download the package for your system and unzip the contents somewhere in your $PATH:

$ sudo tar zxf goon_darwin_amd64.tar.gz -C /usr/local/bin/

By default artifact uses the imagemagick software which is available via your os package manager, homebrew or from http://www.imagemagick.org/.

Setup in 1-2-3

  1. Define a module and use Artifact:

    defmodule ExampleUploader do
      use Artifact, otp_app: :my_app
    end
    
  2. Add the supervisor to your supervisor tree:

    def start(_type, _args) do
      import Supervisor.Spec, warn: false
    
      children = [
    	 supervisor(ExampleUploader.Supervisor, [])
      ]
    
      opts = [strategy: :one_for_one, name: MyApp.Supervisor]
     Supervisor.start_link(children, opts)
    end
    
  3. Update your router to include the generated plug:

    forward "/images", ExampleUploader.Endpoint
    

Configuration

config :my_app, ExampleUploader,
  asset_host: "http://www.example.com/images",
  asset_url: "/:format/:name",
  default: "placeholder.png",
  formats: %{
    thumb: "convert -'[0]' -resize 50x50 -gravity center +repage -strip jpg:-"
  }

config :my_app, ExampleUploader.Storage,
  type: Artifact.Storage.Local,
  storage_dir: Path.expand("../web/static/assets/images", __DIR__)

config :my_app, ExampleUploader.Pool,
  pool_size: 1

Use

iex> {:ok, name} = ExampleUploader.put(data, name: "profile.png")
iex> name
"profile.png"
iex> {:ok, url} = ExampleUploader.URLHelpers.url(name, :thumb)
"http://www.example.com/images/thumb/profile.png"

Phoenix Integration

Using Aritfact with Phoenix? It may be helpful to update your web/web.ex to alias or import the uploader's url helpers:

def view do
  quote do
    use Phoenix.View, root: "web/templates"

    import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1]

    use Phoenix.HTML

    # We'll use an alias with a shorter name
    alias ExampleUploader.URLHelpers, as: Images

    import BevReviews.Router.Helpers
    import BevReviews.ErrorHelpers
    import BevReviews.Gettext
  end
end

Now we can generate URLs in our markup:

<img class="img-responsive img-thumb" src="<%= Images.url(user.avatar, :thumb) %>" alt="">

The value of user.avatar can be both a filename or a subpath from web/static/assets/images/.

License

Artifact source code is released under Apache 2.0 License.

See LICENSE for more information.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory