{"action":"created","issue":{"url":"https://api.github.com/repos/stavro/arc_ecto/issues/4","labels_url":"https://api.github.com/repos/stavro/arc_ecto/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/stavro/arc_ecto/issues/4/comments","events_url":"https://api.github.com/repos/stavro/arc_ecto/issues/4/events","html_url":"https://github.com/stavro/arc_ecto/issues/4","id":105614288,"number":4,"title":"Create option, to specify base path of image urls ","user":{"login":"MartinElvar","id":1180266,"avatar_url":"https://avatars.githubusercontent.com/u/1180266?v=3","gravatar_id":"","url":"https://api.github.com/users/MartinElvar","html_url":"https://github.com/MartinElvar","followers_url":"https://api.github.com/users/MartinElvar/followers","following_url":"https://api.github.com/users/MartinElvar/following{/other_user}","gists_url":"https://api.github.com/users/MartinElvar/gists{/gist_id}","starred_url":"https://api.github.com/users/MartinElvar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartinElvar/subscriptions","organizations_url":"https://api.github.com/users/MartinElvar/orgs","repos_url":"https://api.github.com/users/MartinElvar/repos","events_url":"https://api.github.com/users/MartinElvar/events{/privacy}","received_events_url":"https://api.github.com/users/MartinElvar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-09T14:54:32Z","updated_at":"2015-09-18T23:21:45Z","closed_at":null,"body":"In a typical Phoenix app, you would probably like to store the uploaded the images in the priv/static directory, as it's exposed to the public.\r\n\r\nAs i result i specified the following in my uploader.\r\n\r\n```Elixir\r\n  # Override the storage directory:\r\n  def storage_dir(version, {file, scope}) do\r\n    \"priv/static/images/company/logo/#{scope.id}\"\r\n  end\r\n```\r\n\r\nNow the problem is that, when i try to fetch a url for my model,\r\n\r\n```Elixir\r\n<img src=\"<%= Mobil.Logo.url({company.logo, company}, :thumb) %>\r\n```\r\n\r\nI following path returned \r\n```\r\npriv/static/images/company/logo/1/thumb.png?v=63608960064\r\n```\r\n\r\nWhich is not wrong, but priv/static is exposed, as only what's static folder is, the ideal path would be.\r\n```\r\n/company/logo/1/thumb.png?v=63608960064\r\n```\r\n\r\nSo i guess i need i way to specify, i don't know a base level? of which the url helpers should look in?"},"comment":{"url":"https://api.github.com/repos/stavro/arc_ecto/issues/comments/141592647","html_url":"https://github.com/stavro/arc_ecto/issues/4#issuecomment-141592647","issue_url":"https://api.github.com/repos/stavro/arc_ecto/issues/4","id":141592647,"user":{"login":"posgarou","id":8039360,"avatar_url":"https://avatars.githubusercontent.com/u/8039360?v=3","gravatar_id":"","url":"https://api.github.com/users/posgarou","html_url":"https://github.com/posgarou","followers_url":"https://api.github.com/users/posgarou/followers","following_url":"https://api.github.com/users/posgarou/following{/other_user}","gists_url":"https://api.github.com/users/posgarou/gists{/gist_id}","starred_url":"https://api.github.com/users/posgarou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/posgarou/subscriptions","organizations_url":"https://api.github.com/users/posgarou/orgs","repos_url":"https://api.github.com/users/posgarou/repos","events_url":"https://api.github.com/users/posgarou/events{/privacy}","received_events_url":"https://api.github.com/users/posgarou/received_events","type":"User","site_admin":false},"created_at":"2015-09-18T23:21:45Z","updated_at":"2015-09-18T23:21:45Z","body":"@MartinElvar I've found two things that work now:\r\n\r\n(1) Pipe the path through `Path.relative_to`:\r\n\r\n```elixir\r\ndef logo_url(company) do\r\n  Mobil.Logo.url({company.logo, company}, :thumb)\r\n  |> Path.relative_to(\"priv/static\")\r\nend\r\n```\r\n\r\n(2) Or go with the default uploads directory and specify in `lib/{your_app}/endpoint.ex`, underneath the first `plug Plug.Static`, a second `plug Plug.Static` to serve static assets from the upload directory:\r\n\r\n```elixir\r\n  plug Plug.Static,\r\n    at: \"/uploads\", from: Path.expand('./uploads'), gzip: false\r\n```\r\n\r\nFair warning: I've only been using LocalStorage for sample apps and am using S3 for anything larger than that."}}