{"id":13508356,"url":"https://github.com/doomspork/artifact","last_synced_at":"2025-04-15T06:37:50.525Z","repository":{"id":57479018,"uuid":"51549370","full_name":"doomspork/artifact","owner":"doomspork","description":"File upload and on-the-fly processing for Elixir","archived":false,"fork":false,"pushed_at":"2018-10-15T17:20:30.000Z","size":37,"stargazers_count":44,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T17:11:11.794Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doomspork.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-11T21:46:28.000Z","updated_at":"2023-09-01T11:28:40.000Z","dependencies_parsed_at":"2022-09-17T04:41:54.184Z","dependency_job_id":null,"html_url":"https://github.com/doomspork/artifact","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doomspork%2Fartifact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doomspork%2Fartifact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doomspork%2Fartifact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doomspork%2Fartifact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doomspork","download_url":"https://codeload.github.com/doomspork/artifact/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023423,"owners_count":21199954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:00:51.915Z","updated_at":"2025-04-15T06:37:50.491Z","avatar_url":"https://github.com/doomspork.png","language":"Elixir","funding_links":[],"categories":["Images"],"sub_categories":[],"readme":"# Artifact\n\n\u003e File upload and on-the-fly processing for Elixir\n\n[![Build Status][travis-img]][travis] [![Hex Version][hex-img]][hex] [![License][license-img]][license]\n\n[travis-img]: https://travis-ci.org/doomspork/artifact.png?branch=master\n[travis]: https://travis-ci.org/doomspork/artifact\n[hex-img]: https://img.shields.io/hexpm/v/artifact.svg\n[hex]: https://hex.pm/packages/artifact\n[license-img]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg\n[license]: https://opensource.org/licenses/Apache-2.0\n\n___Artifact is under active development, join the fun!___\n\n## Installation\n\nAdd `artifact` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:artifact, \"~\u003e 0.4\"}]\nend\n```\n\nNext, add :artifact to your list of applications:\n\n```elixir\ndef application do\n  [applications: [:artifact]]\nend\n```\n\nSince ```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:\n\n```bash\n$ sudo tar zxf goon_darwin_amd64.tar.gz -C /usr/local/bin/\n```\n\nBy default ```artifact``` uses the imagemagick software which is available via your os package manager, homebrew or from [http://www.imagemagick.org/](http://www.imagemagick.org/).\n\n## Setup in 1-2-3\n\n1. Define a module and `use` Artifact:\n\n\t```elixir\n\tdefmodule ExampleUploader do\n  \t  use Artifact, otp_app: :my_app\n\tend\n\t```\n\n2. Add the supervisor to your supervisor tree:\n\n\t```elixir\n\tdef start(_type, _args) do\n  \t  import Supervisor.Spec, warn: false\n\n  \t  children = [\n    \t supervisor(ExampleUploader.Supervisor, [])\n  \t  ]\n\n  \t  opts = [strategy: :one_for_one, name: MyApp.Supervisor]\n     Supervisor.start_link(children, opts)\n   end\n   ```\n\n3. Update your router to include the generated plug:\n\n\t```elixir\n\tforward \"/images\", ExampleUploader.Endpoint\n\t```\n\n## Configuration\n\n```elixir\nconfig :my_app, ExampleUploader,\n  asset_host: \"http://www.example.com/images\",\n  asset_url: \"/:format/:name\",\n  default: \"placeholder.png\",\n  formats: %{\n    thumb: \"convert -'[0]' -resize 50x50 -gravity center +repage -strip jpg:-\"\n  }\n\nconfig :my_app, ExampleUploader.Storage,\n  type: Artifact.Storage.Local,\n  storage_dir: Path.expand(\"../web/static/assets/images\", __DIR__)\n\nconfig :my_app, ExampleUploader.Pool,\n  pool_size: 1\n```\n\n## Use\n\n```elixir\niex\u003e {:ok, name} = ExampleUploader.put(data, name: \"profile.png\")\niex\u003e name\n\"profile.png\"\niex\u003e {:ok, url} = ExampleUploader.URLHelpers.url(name, :thumb)\n\"http://www.example.com/images/thumb/profile.png\"\n```\n\n## Phoenix Integration\n\nUsing Aritfact with Phoenix?  It may be helpful to update your `web/web.ex` to alias or import the uploader's url helpers:\n\n```elixir\ndef view do\n  quote do\n    use Phoenix.View, root: \"web/templates\"\n\n    import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1]\n\n    use Phoenix.HTML\n\n    # We'll use an alias with a shorter name\n    alias ExampleUploader.URLHelpers, as: Images\n\n    import BevReviews.Router.Helpers\n    import BevReviews.ErrorHelpers\n    import BevReviews.Gettext\n  end\nend\n```\n\nNow we can generate URLs in our markup:\n\n```erb\n\u003cimg class=\"img-responsive img-thumb\" src=\"\u003c%= Images.url(user.avatar, :thumb) %\u003e\" alt=\"\"\u003e\n```\n\nThe value of ```user.avatar``` can be both a filename or a subpath from ```web/static/assets/images/```.\n\n## License\n\nArtifact source code is released under Apache 2.0 License.\n\nSee [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoomspork%2Fartifact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoomspork%2Fartifact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoomspork%2Fartifact/lists"}