totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

can I receive array or object type parameters with file transfers? #738

Closed luasenvy closed 4 years ago

luasenvy commented 4 years ago

when transferring files via multipart can I receive array or object type parameters in a schemas?

like this:

let formData = new FormData()
formData.append('numbers[]', 1)
formData.append('numbers[]', 2)
formData.append('numbers[]', 3)
// $.model.numbers === [ 1, 2, 3 ]

formData.append('nested[one]', 1)
formData.append('nested[two]', 2)
// $.model.nested === { one: 1, two: 2 }
petersirka commented 4 years ago

Hi, for arrays try this:

formData.append('numbers', 1);
formData.append('numbers', 2);
formData.append('numbers', 3);
// numbers=1&numbers=2&numbers=3

Nested object aren't supported.

My recommendation:

luasenvy commented 4 years ago

Thanks for letting me know :)