The `PutObjectCommand` is used for simple uploads. It allows you to send a file directly to an S3 bucket in a single operation. The `s3Client.send()` method executes this command and handles communication with the AWS service. This is an ideal solution for small files, as it doesn't require any special handling of file splitting or progress tracking.
For large files, the `@aws-sdk/lib-storage` library comes into play. It provides the `Upload` class, which automatically manages splitting the file into multiple parts and uploading them in parallel. This approach optimizes the speed and reliability of the transfer, while simplifying the developer code. You don't need to manually manage the file parts, which significantly reduces complexity. Error handling is also a fundamental aspect. By integrating `try...catch` blocks, you can intercept potential problems, such as an incorrect access key or a dropped connection. The examples provided in the documentation clearly demonstrate how to use PutObjectCommand and Upload, as well as the dependencies required to install