|
|
|
@ -60,14 +60,15 @@ const AddFileForm: FC<AddFileFormProps> = (props) => { |
|
|
|
|
}, {}), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
files.forEach(({ file, name, uuid }) => { |
|
|
|
|
if (!file) return; |
|
|
|
|
const promises = files.reduce<Promise<void>[]>( |
|
|
|
|
(chain, { file, name, uuid }) => { |
|
|
|
|
if (!file) return chain; |
|
|
|
|
|
|
|
|
|
const data = new FormData(); |
|
|
|
|
|
|
|
|
|
data.append('file', new File([file], name, { ...file })); |
|
|
|
|
|
|
|
|
|
api |
|
|
|
|
const promise = api |
|
|
|
|
.post('/file', data, { |
|
|
|
|
headers: { |
|
|
|
|
'Content-Type': 'multipart/form-data', |
|
|
|
@ -93,10 +94,19 @@ const AddFileForm: FC<AddFileFormProps> = (props) => { |
|
|
|
|
setUploadProgress(previous, fileUuid, 100), |
|
|
|
|
); |
|
|
|
|
})(uuid), |
|
|
|
|
) |
|
|
|
|
.catch((error) => { |
|
|
|
|
handleAPIError(error); |
|
|
|
|
}); |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
chain.push(promise); |
|
|
|
|
|
|
|
|
|
return chain; |
|
|
|
|
}, |
|
|
|
|
[], |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
Promise.all(promises).catch((error) => { |
|
|
|
|
const emsg = handleAPIError(error); |
|
|
|
|
|
|
|
|
|
emsg.children = <>Failed to add file. {emsg.children}</>; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
validationSchema: fileListSchema, |
|
|
|
|