Skip to content

Commit

Permalink
fix: upload file
Browse files Browse the repository at this point in the history
  • Loading branch information
richardmichel committed May 24, 2023
1 parent 940dd2e commit d540e5f
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/components/useFileUploadS3Multipart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,14 @@ const useFileUploadS3Multipart = ({
const instance = target.getInstance();

if (detail?.fileStatus === ERROR_STATUS) {
errorCallback({
uuid: null,
fileName: file.name,
message:
'Existió un error al cargar el archivo, intente nuevamente.',
});
if (errorCallback) {
errorCallback({
uuid: null,
fileName: file.name,
message:
'Existió un error al cargar el archivo, intente nuevamente.',
});
}

setDetailProgress(() => {
const payload = {
Expand Down Expand Up @@ -249,12 +251,14 @@ const useFileUploadS3Multipart = ({
return payload;
});

uploadedCallback({
...detail,
fileName: file.name,
mimeType: file.type,
isEmpty,
});
if (uploadedCallback) {
uploadedCallback({
...detail,
fileName: file.name,
mimeType: file.type,
isEmpty,
});
}
});
} catch (errors) {
setDetailProgress(() => {
Expand All @@ -266,12 +270,13 @@ const useFileUploadS3Multipart = ({
}
return payload;
});

errorCallback({
uuid: null,
fileName: file.name,
message: getErrorMessage(errors),
});
if (errorCallback) {
errorCallback({
uuid: null,
fileName: file.name,
message: getErrorMessage(errors),
});
}
}
};

Expand Down

0 comments on commit d540e5f

Please sign in to comment.