What is @aws-sdk/middleware-bucket-endpoint?
The @aws-sdk/middleware-bucket-endpoint package is part of the AWS SDK for JavaScript (v3). It provides middleware that automatically configures the endpoint for S3 bucket operations, allowing users to interact with different S3 bucket configurations and regions more seamlessly. This package is particularly useful for managing requests to S3 buckets by modifying the endpoint based on the operation and the provided bucket parameters.
What are @aws-sdk/middleware-bucket-endpoint's main functionalities?
Automatic Endpoint Resolution
This code sample demonstrates how to integrate the bucketEndpointMiddleware into an S3 client instance. It automatically resolves the correct endpoint for the bucket specified in the command.
import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3';
import { bucketEndpointMiddleware } from '@aws-sdk/middleware-bucket-endpoint';
const client = new S3Client({
region: 'us-west-2',
middlewareStack: {
add: (middleware) => middleware(bucketEndpointMiddleware())
}
});
const command = new GetObjectCommand({ Bucket: 'example-bucket', Key: 'example-object' });
client.send(command);
Other packages similar to @aws-sdk/middleware-bucket-endpoint
@aws-sdk/middleware-sdk-s3
This package includes various middleware utilities for S3 operations within the AWS SDK for JavaScript. It offers functionalities similar to @aws-sdk/middleware-bucket-endpoint but is broader in scope, covering more aspects of S3 interactions beyond just endpoint resolution.
@aws-sdk/s3-request-presigner
While primarily focused on generating pre-signed URLs for S3 requests, this package interacts with S3 endpoints in a manner that complements the functionalities provided by @aws-sdk/middleware-bucket-endpoint. It handles endpoint resolution implicitly when generating URLs.