Alvinkariuki
Failed file upload test
I’m currently trying to tests file upload functionality for multiple files, here is a snippet of the code in a form
files =
file_input(live, "#upload_form", :files, [
%{
last_modified: 1_551_913_973,
name: "file_1.png",
content: File.read!("test/live/sample.png"),
size: 512_623,
type: "image/png"
},
%{
last_modified: 1_551_913_974,
name: "file_2.png",
content: File.read!("test/live/sample.png"),
size: 512_623,
type: "image/png"
}
])
form_preupload =
live
|> form("#upload_form",
some_form: %{
user_name: "Employ",
start_date: "2023-07-19",
}
}
)
render_upload(
files,
"file_1.png"
)
render_upload(
files,
"file_1.png"
)
render_submit(form_preupload)
everything works fine till the render submit. to which I get this error
** (RuntimeError) cannot consume uploaded file that is still in progress
the files are being consumed with consume_uploaded_entry/3 in a loop for loop
What could the problem possibly be
Most Liked
trisolaran
Check whether the size value you pass to file_input matches the size of the content. I get the error you’re seeing when they differ.
To be on the safe side, do not hard code the size value but set it directly from the file content. This is what I do in one of my tests:
file_content = File.read!(Path.join(__DIR__, "two_sigma.csv"))
file_upload =
file_input(view, "#resolution_form", :ledes_file, [
%{
name: new_file_name,
type: "text/csv",
size: byte_size(file_content),
content: file_content
}
])
1
Popular in Questions
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









