BillBryson
I’m trying to use waffle to handle the upload with LiveView uploads and receive the following error: [error] {:error, :invalid_file_path}.
I’m building a %Plug.Upload{content_type: content_type, filename: filename, path: path} struct which is then sent over as the “image” attribute to my schema that has my Waffle uploader type for field image. But in the cast_attachments function it returns the error changeset:
#Ecto.Changeset<
action: nil,
changes: %{title: "foo"},
errors: [
image: {"is invalid",
[type: MyAppWeb.Uploaders.PostImage.Type, validation: :cast]}
],
data: #MyApp.Blog.Post<>,
valid?: false
>
The attributes being passed to the schema changeset are:
%{
"title" => "foo",
"image" => %Plug.Upload{
content_type: "image/png",
filename: "blog-title.png",
path: "/var/folders/mt/9c2zqzy93tg5xfl7317j7m340000gn/T//plug-1619/live_view_upload-1619366353-634670199203471-4"
}
}
I have tried without the LiveView and it works, but only difference I can see is in the path set on the upload.
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
cenotaph
Liveview already has a dedicated file upload section with the necessary methods, js functions.
Is there a specific reason you don’t want to use those and replicate the work with waffle integration?
BillBryson
Mostly because I am making use of the image transformations/versions that Waffle makes easy to do. If my situation were more direct upload and no any image manipulation I would use the those instructions.
cenotaph
Regardless of your answer, there is no plug on LIve View. Transfer happens with the socket, help of JS and multipart binary form.
That is why cast is coming empty
cenotaph
Do you use imagemagick for your modifications? If so it will just be an addition to the example code.
convert -define jpeg:size=200x200 original.jpeg -thumbnail 100x100^ -gravity center -extent 100x100 thumbnail.jpegBillBryson
I do see other people have had luck LiveView support · Issue #71 · elixir-waffle/waffle · GitHub and am trying to follow that example of building my own
%Plug.Upload{}that then is passed into the changeset.Yes, you are right that I could simply write my own image conversions, but our team preference is to use a standardized library that has tests/documentation.
kokolegorille
The path is the filename… You might have to copy the file to a tmp file, then use it in Plug.Upload.
BillBryson
Oh do I have this mixed up? Should it be:
kokolegorille
Maybe, You should try
I remember having this issue too. Until I realized path was the filename.
But I do not remember why I think it was easier to make a copy first, instead of using the tmp file directly.
BillBryson
Sorry I was away from the computer. I have tried this now still with no luck. I did compare the contents of the
%Plug.Upload{}without LiveView:This does work without live view. And changing the path to filename did not work. I will try the copy to a tmp file and then use that in the
%Plug.Upload{}. I am still not sure why this does not work.