You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have used your code as a reference for multi part upload and the problem I am facing is my complete multipart upload gets executed before my any one part of the file starts upload.
I have created a for loop inside which i am initializing partnumber, partSizeToupload, dataToUpload, and position. Then API call to my backend server in Django to get presigned URL and when the API successfully gets called PUT call to upload that object.
My complete multipart upload API call is outside my for loop and on debugging I get to know it gets executed my for loop is executing.
Below is my code to do this task:
const partSize = 1024 * 1024 * 5;
const wavSize = wav.byteLength;
const partCount = parseInt(Math.ceil(wavSize / parseFloat(partSize, 10)), 10);
// let fileData = {};
let partNum = 0;
let position = 0;
let iterator = 0;
const uploadPartsArray = [];
let promisesArray = [];
for ( iterator = 0; iterator < partCount; iterator++) {
partNum = iterator + 1;
const partSizeToUpload = Math.min(partSize, (wavSize - position));
const dataToUpload = wav.slice(position, partSizeToUpload);
position = position + partSizeToUpload;
apiService.uploadFilePart(this.props.meetingData.meeting.uuid, { upload_id: responseUrl.data.upload_id, key: responseUrl.data.file_key, file_part_number: partNum})
.then((responseUploadPart) => {
console.log('I am response from uploadFIlePart: ', responseUploadPart);
const uploadRespPromise = apiService.uploadAudioRecording(responseUploadPart.data.url, dataToUpload, { headers: {'Access-Control-Expose-Headers': '*'} })
.then((responseUpload) => {
console.log('Upload AUdio iam response headers: ', responseUpload.headers.etag);
uploadPartsArray.push({
ETag: responseUpload.headers.etag,
PartNumber: partNum
});
console.log('Upload parts array: ', uploadPartsArray);
}).catch(error => { console.log('Error in uploading to presigned URL..', error); });
promisesArray.push(uploadRespPromise);
}).catch(error => { console.log('Error in API call of uploadFIlepart..', error);});
}
// Complete Multi part upload
const resolvedArray = await Promise.all(promisesArray);
console.log(resolvedArray, ' resolvedArray');
console.log('Final Upload parts array: ', uploadPartsArray);
apiService.completeMultipartUpload(this.props.meetingData.meeting.uuid, { upload_id: responseUrl.data.upload_id, key: responseUrl.data.file_key, file_parts: uploadPartsArray })
.then((responseCompleteMltipart) => {
console.log('Multi part upload response: ', responseCompleteMltipart);
})
.catch((errCMU) => { console.log('Error in completing multipart upload..,', errCMU); } );
The text was updated successfully, but these errors were encountered:
I have used your code as a reference for multi part upload and the problem I am facing is my complete multipart upload gets executed before my any one part of the file starts upload.
I have created a for loop inside which i am initializing partnumber, partSizeToupload, dataToUpload, and position. Then API call to my backend server in Django to get presigned URL and when the API successfully gets called PUT call to upload that object.
My complete multipart upload API call is outside my for loop and on debugging I get to know it gets executed my for loop is executing.
Below is my code to do this task:
const partSize = 1024 * 1024 * 5;
const wavSize = wav.byteLength;
const partCount = parseInt(Math.ceil(wavSize / parseFloat(partSize, 10)), 10);
// let fileData = {};
let partNum = 0;
let position = 0;
let iterator = 0;
const uploadPartsArray = [];
let promisesArray = [];
for ( iterator = 0; iterator < partCount; iterator++) {
partNum = iterator + 1;
const partSizeToUpload = Math.min(partSize, (wavSize - position));
const dataToUpload = wav.slice(position, partSizeToUpload);
position = position + partSizeToUpload;
The text was updated successfully, but these errors were encountered: