What is @aws-sdk/middleware-flexible-checksums?
@aws-sdk/middleware-flexible-checksums is a middleware package for the AWS SDK for JavaScript. It provides functionality to handle flexible checksums for AWS services, ensuring data integrity during transmission.
What are @aws-sdk/middleware-flexible-checksums's main functionalities?
Adding Checksum to Requests
This feature allows you to add a checksum to your S3 PutObject requests to ensure data integrity during transmission.
const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3');
const { flexibleChecksumsMiddleware } = require('@aws-sdk/middleware-flexible-checksums');
const client = new S3Client({
region: 'us-west-2',
});
client.middlewareStack.add(flexibleChecksumsMiddleware(), {
step: 'build',
priority: 'high',
});
const command = new PutObjectCommand({
Bucket: 'example-bucket',
Key: 'example-key',
Body: 'Hello, world!',
});
client.send(command).then((response) => {
console.log('Success', response);
}).catch((error) => {
console.error('Error', error);
});
Validating Checksum in Responses
This feature allows you to validate the checksum in the response from an S3 GetObject request to ensure data integrity.
const { S3Client, GetObjectCommand } = require('@aws-sdk/client-s3');
const { flexibleChecksumsMiddleware } = require('@aws-sdk/middleware-flexible-checksums');
const client = new S3Client({
region: 'us-west-2',
});
client.middlewareStack.add(flexibleChecksumsMiddleware(), {
step: 'deserialize',
priority: 'high',
});
const command = new GetObjectCommand({
Bucket: 'example-bucket',
Key: 'example-key',
});
client.send(command).then((response) => {
console.log('Success', response);
}).catch((error) => {
console.error('Error', error);
});
Other packages similar to @aws-sdk/middleware-flexible-checksums
aws-sdk
The 'aws-sdk' package is the official AWS SDK for JavaScript. It provides a comprehensive set of tools for interacting with AWS services, including S3. While it does not specifically focus on flexible checksums, it offers a wide range of functionalities for AWS services.
aws4
The 'aws4' package is a lightweight library for signing AWS requests using AWS Signature Version 4. It does not provide checksum functionality but is useful for securely signing requests to AWS services.
s3-upload-stream
The 's3-upload-stream' package is a Node.js library for streaming uploads to Amazon S3. It focuses on streaming data to S3 and does not provide checksum functionality, but it is useful for handling large file uploads.