Where Arc is triggered when upload a file?


I’m using Arc and Arc Ecto to upload a file and I see nowhere explicit usage of store function yet it works. I read source code and I don’t see anything strange here - lot of __using__ which creates functions and in proper Arc.Storage (Local or S3) file is created.

I just don’t see how my code triggers Arc.

1 Like

Your code does not triggers store directly I guess, but you had to call cast_attachments to make it work.

It maps through params, picks the uploaded files Plug.Upload, extracts the emporary paths, then, it calls cast:

Since your schema defines the fields as custom type, Ecto knows that a cast function from this module should be called. And since it is present and included from arc, it does get called, and call store:


Thanks, I didn’t check the Arc.Ecto.
Great job! :slight_smile: