AWS Cloud Architecture•Part 4: Storage, Content Delivery & Databases (36 - 50)
S3 Multipart Upload.
In Simple Words: Uploads large files in parallel chunks (parts). Mandatory for files > 5 GB (recommended for > 100 MB). If one part fails due to network interruption, only that part needs to be retried rather than re-uploading the entire file.
typescript
import { S3Client } from '@aws-sdk/client-s3';
import { Upload } from '@aws-sdk/lib-storage';
import fs from 'fs';
const upload = new Upload({
client: new S3Client({}),
params: {
Bucket: 'my-bucket',
Key: 'large-dataset.zip',
Body: fs.createReadStream('large-dataset.zip')
},
partSize: 10 * 1024 * 1024, // 10MB chunk parts
queueSize: 4 // 4 parallel uploads
});
await upload.done();