Replies: 1 comment 1 reply
-
When I lost many time on non working multi file upload, I was surprised why it's not supported. Moreover, fix is trivial, something like [ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
if (Array.isArray(property) && property.every(p => p instanceof Blob)) {
property.forEach(p => formData.append(key, p));
} else {
formData.append(
key,
property instanceof Blob
? property
: typeof property === 'object' && property !== null
? JSON.stringify(property)
: `${property}`,
);
}
return formData;
}, new FormData()), |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Having a use case where we need to upload multiple files at the same time, seems like the underlying logic is not considering arrays.
Consider following scenario when
data
is something like this:and having
uploadPost
method like this:The
contentFormatters
method is in question here as it is called within therequest
and transformsObject
toFormData
but not consideringproperty
to be anArray
:Are we doing something wrong or multi-file upload is not supported?
Beta Was this translation helpful? Give feedback.
All reactions