How do you validate file uploads, especially images sended via forms?

Hello the forum. ^^
Please, in phoenix guides, I read that it would be preferable to use a library for file upload validations. Does that mean Phoenix Plug.Upload doesn’t ship any validators ?

Well I tried arc_ecto which seems to be the most popular, and I was more or less satisfied with. But the big problem is that it seems that this library is no longer maintained.
That’s why, I would like now to handle image uploads by myself, in my current phoenix (and the first) project.

So I would like to know, when uploading, the good way for :

  • validating image extensions (for a given upload form field)
  • limiting image weight (if possible for a given upload form field)

After validation I will resize the uploaded image and create maybe 2 versions like Arc library ways : an original et thumbnail for example.
For this at least I plan to use a library to keep things simple. i’m hesitating between Mogrify and ExfileImagemagick. But if you have some suggestions, it will be fine of course. ^^

I would suggest considering using Arc for this.

1 Like

Thank you for your suggestion. I guess I don’t really have the choice. I just hope Arc will fit well with Phoenix 1.3 that I’m using for my project. I’ve seen a little bug about it on their site but that isn’t really a big deal. I will be doing with Arc for now.

I used it on 1.3, works fine.

1 Like

Ok thanks again. I’m reassured. :smile:

1 Like