Closed ganigeorgiev closed 10 months ago
A partial fix was implemented in master
.
The "fix" is partial because there are still 2 edge cases that are not handled - when a json
field value is empty array (eg. []
) or array of strings (eg. ["a","b"]
).
The reason for this is because the SDK doesn't have information about the field types and doesn't know which field is a json
or an arrayable select
, file
or relation
, so it can't serialize it properly on its own as FormData
string value.
If you are having troubles with persisting json
values as part of a multipart/form-data
request the easiest fix for now is to manually stringify the json
field value:
await pb.collection("example").create({
// having a Blob/File as object value will convert the request to multipart/form-data
"someFileField": new Blob([123]),
"someJsonField": JSON.stringify(["a","b","c"]),
})
A proper fix for this will be implemented with PocketBase v0.21.0 where we'll have support for a special @jsonPayload
multipart body key, which will allow us to submit mixed multipart/form-data
content (kindof similar to the multipart/mixed
MIME).
Related to https://github.com/pocketbase/pocketbase/issues/4150.