diff --git a/src/components/data-management/metadata/AddMetadataButton.jsx b/src/components/data-management/metadata/AddMetadataButton.jsx index 50895afec1..004a4b7501 100644 --- a/src/components/data-management/metadata/AddMetadataButton.jsx +++ b/src/components/data-management/metadata/AddMetadataButton.jsx @@ -59,7 +59,7 @@ const AddMetadataButton = ({ samplesTableRef }) => { } try { - await prepareAndUploadFileToS3(file, uploadUrlParams, 'cellLevelMeta', onUpdateUploadStatus); + await prepareAndUploadFileToS3(file, uploadUrlParams, 'cellLevelMeta', new AbortController(), onUpdateUploadStatus); } catch (e) { pushNotificationMessage('error', 'Something went wrong while uploading your metadata file.'); console.log(e); diff --git a/src/utils/upload/processMultipartUpload.js b/src/utils/upload/processMultipartUpload.js index 6a85da268e..fa5493044c 100644 --- a/src/utils/upload/processMultipartUpload.js +++ b/src/utils/upload/processMultipartUpload.js @@ -4,14 +4,14 @@ const FILE_CHUNK_SIZE = 10000000; const MAX_RETRIES = 2; const putPartInS3 = async ( - blob, signedUrl, onUploadProgress, currentRetry = 0, abortController = null, + blob, signedUrl, onUploadProgress, abortController, currentRetry = 0, ) => { try { return await axios.request({ method: 'put', data: blob, url: signedUrl, - signal: abortController?.signal, + signal: abortController.signal, headers: { 'Content-Type': 'application/octet-stream', }, @@ -19,7 +19,9 @@ const putPartInS3 = async ( }); } catch (e) { if (currentRetry < MAX_RETRIES) { - return await putPartInS3(blob, signedUrl, onUploadProgress, currentRetry + 1); + return await putPartInS3( + blob, signedUrl, onUploadProgress, abortController, currentRetry + 1, + ); } throw e; @@ -42,8 +44,8 @@ const processMultipartUpload = async ( blob, signedUrl, createOnUploadProgressForPart(index), - 0, abortController, + 0, ); promises.push(req); diff --git a/src/utils/upload/processUpload.js b/src/utils/upload/processUpload.js index 5668e98e87..85b0924c7f 100644 --- a/src/utils/upload/processUpload.js +++ b/src/utils/upload/processUpload.js @@ -18,7 +18,7 @@ import endUserMessages from 'utils/endUserMessages'; import pushNotificationMessage from 'utils/pushNotificationMessage'; const prepareAndUploadFileToS3 = async ( - file, uploadUrlParams, type, onStatusUpdate = () => { }, abortController = null, + file, uploadUrlParams, type, abortController, onStatusUpdate = () => { }, ) => { let parts = null; const { signedUrls, uploadId, fileId } = uploadUrlParams; @@ -121,7 +121,7 @@ const createAndUploadSampleFile = async (file, experimentId, sampleId, dispatch, ); const uploadUrlParams = { signedUrls, uploadId, fileId: sampleFileId }; - await prepareAndUploadFileToS3(file, uploadUrlParams, 'sample', updateSampleFileUploadProgress, abortController); + await prepareAndUploadFileToS3(file, uploadUrlParams, 'sample', abortController, updateSampleFileUploadProgress); } catch (e) { dispatch(updateSampleFileUpload( experimentId, sampleId, sampleFileId, fileType, UploadStatus.UPLOAD_ERROR,