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
Uh oh!
There was an error while loading. Please reload this page.
-
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
datais something like this:and having
uploadPostmethod like this:The
contentFormattersmethod is in question here as it is called within therequestand transformsObjecttoFormDatabut not consideringpropertyto be anArray:Are we doing something wrong or multi-file upload is not supported?
Beta Was this translation helpful? Give feedback.
All reactions