Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config option for Arc.Storage.Local directory #65

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jbrowning
Copy link

This PR introduces a local_dir config option that allows one to specify a prefix for the Arc.Storage.Local location. This is especially useful for running tests.

Example usage:

# config/test.exs
config :arc, local_dir: "test/uploads"

defmodule MyApp.Avatar.Uploader do
  use Arc.Definition
  use Arc.Ecto.Definition

  def __storage, do: Arc.Storage.Local

  def storage_dir(_version, {_file, _scope}) do
    "avatars"
  end
end

MyApp.Avatar.Uploader.store(%Plug.Upload{filename: "file.png", path: "/a/b/c"})
# File will be stored in "test/uploads/avatars"

@merqlove
Copy link

merqlove commented Jun 5, 2016

nice one pr

@jerodsanto
Copy link
Contributor

I'd like to add my hardy 👍 to this feature. For changelog.com we do a similar thing so that we can have Arc upload to priv/uploads in dev and to /uploads in prod (we store files outside app directory and have nginx server them).

Then we do this in our uploaders:

def storage_dir(_version, {_file, scope}) do
  "#{Application.fetch_env!(:arc, :storage_dir)}/#{scope.podcast.slug}/#{scope.slug}"
end

Having this supported out of the box would be super cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants