I have a problem.
In my lambda function I have to split a file from an s3 bucket into multiple parts to perform a multipartUpload to copy the file to the same bucket but to a different folder.
I tried different methods but nothing works, so I started to turn the file into a Buffer, now, how can I split the Buffer into limited parts based on the memory size?
Example: my file is 1000MB in size, how can I divide this buffer into 10 parts of 100MB each?
Here my code:
const fileBuffer = Buffer.from(srcKey);
console.log('##### 2. BUFFER: ', fileBuffer);
// I tried this but seems doesn't work in the way i want...
const numOfParts = Number((fileSize / (100 * 1024 * 1024)).toString().split('.')[0]);
const chunks = fileBuffer.slice(numOfParts);
console.log('###### 3. NofParts: ', numOfParts, ', Nchunks: ', chunks.length);