You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Its a good pattern for multipart data to include both data and files. I implemented this pattern internally, but I think it would offer a good out of the box convenience.
The idea is that given this data object:
{
"name": "John doe",
"profileImage": File
}
To send it to the backend, we must send it using FormData like this:
the frontend would need to handle structuring the payload. In my implementation, I do a recursive search of the data and replace all File objects with a reference (e.g. file_x) and append the file at the end of the FormData. Then I stringify the payload into data
On the backend, I essentially do the reverse to rebuild the original data structure, and then pass it through the validator.
Let me know your thoughts.
Additional information
Would you be willing to help implement this feature?
The text was updated successfully, but these errors were encountered:
Describe the feature
Its a good pattern for multipart data to include both data and files. I implemented this pattern internally, but I think it would offer a good out of the box convenience.
The idea is that given this data object:
To send it to the backend, we must send it using FormData like this:
In a route, we would do:
The opinionated aspects:
data
and replace allFile
objects with a reference (e.g.file_x
) and append the file at the end of theFormData
. Then I stringify the payload intodata
Let me know your thoughts.
Additional information
The text was updated successfully, but these errors were encountered: