Phoenix 1.3 ... how to configure Arc or Arc_ecto?

hello, how to use Arc && arc_ecto? I have an app that allows users to upload their avatar/picture and other files.
Or is it better for the moment to use the default plug.upload ? if yes, how to achieve this?

1 Like

I guess Arc’s configuration shouldn’t be much different that in previous Phoenix versions- you have entry for arc in config.exs and for schema you are interested to use file upload, you use proper uses of Arc.Definition and Arc.Ecto.Definition.

I used in my own projects Arc and Arc_ecto, but in the company product we considered Arc to be to much erroneous - upload didn’t work so we decided to drop using Arc at all and it concluded that I wrote simple uploader on my own, which relies on ex_aws.

Basically - Arc creates it’s own file based on the input - it requires filename and binary, so it wraps a map or Plug.Upload to do the upload.

Maybe the function definition of ExAws.S3.put_object/4 is not self explanatory, but it wants you to pass:

  • name of the S3 bucket
  • file destination
  • file content - binary
  • additional options like ACL

With that knowledge you can intercept Plug Upload and use ex_aws directly without Arc.

I guess you can still keep uploaders in lib/myapp/web.


@PatNowak thanks for your reply and advise, I checked deeply, and correct me if said something wrong: it seems that the Phoenix 1.3 release don’t use the web/ folder and the model concept anymore but context etc… that’s not the case with Arc or Arc_ecto, it generated false structure in the phoenix 1.3 app.
And in the case we’re managing to store user’s uploaded picture locally and we have a specified context & schema in our app, how it’d look like?

1 Like

Yes, there is no web folder in the root folder, but there’s lib/myapp/web where all the parts of the app you know - controllers, templates etc. - exist.
You also right about models, there are no model folder, but your code is bundled into bounded contexts and related schemas to them, but it doesn’t change the way how Arc works.
You simply use these lines:

use Arc.Definition
use Arc.Ecto.Definition

And it doesn’t care where your code is, as long it’s an schema’s module.

1 Like

ok Thanks for your reply! I’ll try it, and I’m opened to other advises! :sweat_smile:

1 Like

You got here a fully functional project, it’s a bit mess, because I used to test for real projects, but has both arc, arc_ecto S3 and a few other things…


I haven’t been able to get arc_ecto working with Phoenix 1.3 either. Specifically the schema file has issues.

Specifically this line in the schema

field :image, MyApp.ImageUploader.Type

returns this error

web_1 | ** (ArgumentError) invalid or unknown type MyApp.ImageUploader.Type for field :image

Even though this module was generated using the Arc generator.

Has anyone made progress here?


Figured it out. The Arc generator was putting the ImageUploader module in a folder called /web, which is defunct in Phoenix 1.3.

I moved this file to /lib/myapp_web/uploaders/image_uploader.ex and was able to get moving.