amazon s3 – How to track the upload progress in Node.js in S3 using aws sdk v3

Is it possible to track the upload progress of S3 by PutObjectCommand from @aws-sdk/client-s3 ?

response.on('end', async () => {
  try {
    console.log('File downloaded successfully!');
    console.log('File deleted from Seedr.cc!');

    socket.emit('message', 'Successfully downloaded "' + downloadPath + '" to API server, File deleted from Seedr.cc');
    await seedr.deleteFolder(selectedVideo.fid);

    // Upload the file to S3
    const fileContent = fs.createReadStream(downloadPath);
    uploadParams.Body = fileContent;

    socket.emit('message', 'Uploading "' + s3key + '" to S3.');

    const uploadCommand = new PutObjectCommand(uploadParams);
    await s3.send(uploadCommand);

    console.log(`File uploaded to S3 bucket: ${S3_BUCKET}`);

    // Remove the downloaded file from the server
    fs.unlinkSync(downloadPath);

    // Notify the client that the operation is complete
    socket.emit('message', `Successfully uploaded "${s3key}" to S3 and file deleted from local server`);

    activeDownloads.delete(s3key);
  } catch (error) {
    console.error(`Error after file download: ${error}`);
    socket.emit('error', {
      s3key,
      message: `Error after file download: ${error.message}`,
    });
    activeDownloads.delete(s3key);
  }
});

It was easy when I was using sdk v2 but in v3 I’m not able to get any solution.

Read more here: Source link