alfred
alfred copied to clipboard
If the same key name in formdata
Hello,
I am trying to send multiple keys/value with the same key name using the post method using form-data.
However, I can only get the last one of the values with the same key name.
My goal is to upload images to the server using the same key like file[] name but I can only get the last one.
How can I handle form-data keys using the same key name?
Form-Data looks like this.
name = "John" Age = 24 file[] = Image1.jpg file[] = Image2.jpg file[] = Image3.jpg file[] = Image4.jpg
Whenever I check the incoming data, only image4 is read. What I want to do is to loop and process how many file[] there are.
When sending the Form-Data, I can make the key names as file[1] file[2], but I wonder why I can't do this by sending the same name, is this feature not supported or did I fail.
PS: Thank you very much for the beautiful package, it is a great job.
Hey,
sorry for the late reply. The parsing is performed by an old official dart library from google that was discontinued, who while I haven't dug into it heavily, I would suggest its probably one of those things thats not supported right now but should be. So you didn't fail! For now use the workaround but I will keep the issue open and i'll have a look into when I'm poking around that part of the package.
So a bit more information here - it seems dart just doesn't know how to do arrays with form data. I came across this separately trying to do a call to stripe when setting up my web store. The dart stripe library has it worked out and i'll see if I can implement what they have done.