Closed VadimDez closed 1 day ago
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:
data
const data = { files: [ new File([], '1.txt'), new File([], '2.txt') ] }
and having uploadPost method like this:
uploadPost
uploadPost: (data: BodyUploadPost, params: RequestParams = {}) => this.request<MessageResponse, HTTPValidationError>({ path: `/api/upload-files`, method: "POST", body: data, type: ContentType.FormData, format: "json", ...params, }),
The contentFormatters method is in question here as it is called within the request and transforms Object to FormData but not considering property to be an Array:
contentFormatters
request
Object
FormData
property
Array
[ContentType.FormData]: (input: any) => Object.keys(input || {}).reduce((formData, key) => { const property = input[key]; formData.append(key, property instanceof Blob ? property : typeof property === "object" && property !== null ? JSON.stringify(property) : `${property}`); return formData; }, new FormData()),
Are we doing something wrong or multi-file upload is not supported?
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?