clients/client-s3/README.md
AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native.
<note> <p>For information about using the Amazon S3 API—including authentication, signing requests, code examples, and error handling—see the <a href="https://docs.aws.amazon.com/AmazonS3/latest/developerguide/Welcome.html">Amazon S3 Developer Guide</a>.</p> </note> <p>Welcome to the <i>Amazon S3 API Reference</i>. This guide explains the Amazon Simple Storage Service (Amazon S3) application programming interface (API).</p> <p>Welcome to the <i>Amazon S3 API Reference</i>. This guide explains the Amazon Simple Storage Service (Amazon S3) application programming interface (API).</p> <p>You can use any toolkit that supports HTTP to use the REST API. You can even use a browser to fetch objects, as long as they are anonymously readable.</p> <p>The REST API uses the standard HTTP headers and status codes, so that standard browsers and toolkits work as expected. In some areas, we have added functionality to HTTP (for example, we added headers to support access control). In these cases, we have done our best to add the new functionality in a way that matched the style of standard HTTP usage.</p> <p>The current version of the Amazon S3 API is <code>2006-03-01</code>.</p> <p>Amazon S3 supports the REST API.</p> <note> <p>Support for SOAP over HTTP is deprecated, but it is still available over HTTPS. However, new Amazon S3 features will not be supported for SOAP. We recommend that you use either this REST API or the Amazon Web Services SDKs.</p> </note>To install this package, use the CLI of your favorite package manager:
npm install @aws-sdk/client-s3yarn add @aws-sdk/client-s3pnpm add @aws-sdk/client-s3The AWS SDK is modulized by clients and commands.
To send a request, you only need to import the S3Client and
the commands you need, for example ListBucketsCommand:
// ES5 example
const { S3Client, ListBucketsCommand } = require("@aws-sdk/client-s3");
// ES6+ example
import { S3Client, ListBucketsCommand } from "@aws-sdk/client-s3";
To send a request:
send operation on the client, providing the command object as input.const client = new S3Client({ region: "REGION" });
const params = { /** input parameters */ };
const command = new ListBucketsCommand(params);
We recommend using the await operator to wait for the promise returned by send operation as follows:
// async/await.
try {
const data = await client.send(command);
// process data.
} catch (error) {
// error handling.
} finally {
// finally.
}
You can also use Promise chaining.
client
.send(command)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
})
.finally(() => {
// finally.
});
The aggregated client class is exported from the same package, but without the "Client" suffix.
S3 extends S3Client and additionally supports all operations, waiters, and paginators as methods.
This style may be familiar to you from the AWS SDK for JavaScript v2.
If you are bundling the AWS SDK, we recommend using only the bare-bones client (S3Client).
More details are in the blog post on
modular packages in AWS SDK for JavaScript.
import { S3 } from "@aws-sdk/client-s3";
const client = new S3({ region: "REGION" });
// async/await.
try {
const data = await client.listBuckets(params);
// process data.
} catch (error) {
// error handling.
}
// Promises.
client
.listBuckets(params)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
});
// callbacks (not recommended).
client.listBuckets(params, (err, data) => {
// process err and data.
});
When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).
try {
const data = await client.send(command);
// process data.
} catch (error) {
const { requestId, cfId, extendedRequestId } = error.$metadata;
console.log({ requestId, cfId, extendedRequestId });
/**
* The keys within exceptions are also parsed.
* You can access them by specifying exception names:
* if (error.name === 'SomeServiceException') {
* const value = error.specialKeyInException;
* }
*/
}
See also docs/ERROR_HANDLING.
Please use these community resources for getting help. We use GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.
aws-sdk-js
on AWS Developer Blog.aws-sdk-js.To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.
This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-s3 package is updated.
To contribute to client you can check our generate clients scripts.
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.
Command API Reference / Input / Output
</details> <details> <summary> CompleteMultipartUpload </summary>Command API Reference / Input / Output
</details> <details> <summary> CopyObject </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateBucket </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateBucketMetadataConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateBucketMetadataTableConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateMultipartUpload </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateSession </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucket </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketAnalyticsConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketCors </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketEncryption </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketIntelligentTieringConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketInventoryConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketLifecycle </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketMetadataConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketMetadataTableConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketMetricsConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketOwnershipControls </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketPolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketReplication </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketTagging </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteBucketWebsite </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteObject </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteObjectAnnotation </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteObjects </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteObjectTagging </summary>Command API Reference / Input / Output
</details> <details> <summary> DeletePublicAccessBlock </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketAbac </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketAccelerateConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketAcl </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketAnalyticsConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketCors </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketEncryption </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketIntelligentTieringConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketInventoryConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketLifecycleConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketLocation </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketLogging </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketMetadataConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketMetadataTableConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketMetricsConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketNotificationConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketOwnershipControls </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketPolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketPolicyStatus </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketReplication </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketRequestPayment </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketTagging </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketVersioning </summary>Command API Reference / Input / Output
</details> <details> <summary> GetBucketWebsite </summary>Command API Reference / Input / Output
</details> <details> <summary> GetObject </summary>Command API Reference / Input / Output
</details> <details> <summary> GetObjectAcl </summary>Command API Reference / Input / Output
</details> <details> <summary> GetObjectAnnotation </summary>Command API Reference / Input / Output
</details> <details> <summary> GetObjectAttributes </summary>Command API Reference / Input / Output
</details> <details> <summary> GetObjectLegalHold </summary>Command API Reference / Input / Output
</details> <details> <summary> GetObjectLockConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> GetObjectRetention </summary>Command API Reference / Input / Output
</details> <details> <summary> GetObjectTagging </summary>Command API Reference / Input / Output
</details> <details> <summary> GetObjectTorrent </summary>Command API Reference / Input / Output
</details> <details> <summary> GetPublicAccessBlock </summary>Command API Reference / Input / Output
</details> <details> <summary> HeadBucket </summary>Command API Reference / Input / Output
</details> <details> <summary> HeadObject </summary>Command API Reference / Input / Output
</details> <details> <summary> ListBucketAnalyticsConfigurations </summary>Command API Reference / Input / Output
</details> <details> <summary> ListBucketIntelligentTieringConfigurations </summary>Command API Reference / Input / Output
</details> <details> <summary> ListBucketInventoryConfigurations </summary>Command API Reference / Input / Output
</details> <details> <summary> ListBucketMetricsConfigurations </summary>Command API Reference / Input / Output
</details> <details> <summary> ListBuckets </summary>Command API Reference / Input / Output
</details> <details> <summary> ListDirectoryBuckets </summary>Command API Reference / Input / Output
</details> <details> <summary> ListMultipartUploads </summary>Command API Reference / Input / Output
</details> <details> <summary> ListObjectAnnotations </summary>Command API Reference / Input / Output
</details> <details> <summary> ListObjects </summary>Command API Reference / Input / Output
</details> <details> <summary> ListObjectsV2 </summary>Command API Reference / Input / Output
</details> <details> <summary> ListObjectVersions </summary>Command API Reference / Input / Output
</details> <details> <summary> ListParts </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketAbac </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketAccelerateConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketAcl </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketAnalyticsConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketCors </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketEncryption </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketIntelligentTieringConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketInventoryConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketLifecycleConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketLogging </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketMetricsConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketNotificationConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketOwnershipControls </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketPolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketReplication </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketRequestPayment </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketTagging </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketVersioning </summary>Command API Reference / Input / Output
</details> <details> <summary> PutBucketWebsite </summary>Command API Reference / Input / Output
</details> <details> <summary> PutObject </summary>Command API Reference / Input / Output
</details> <details> <summary> PutObjectAcl </summary>Command API Reference / Input / Output
</details> <details> <summary> PutObjectAnnotation </summary>Command API Reference / Input / Output
</details> <details> <summary> PutObjectLegalHold </summary>Command API Reference / Input / Output
</details> <details> <summary> PutObjectLockConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> PutObjectRetention </summary>Command API Reference / Input / Output
</details> <details> <summary> PutObjectTagging </summary>Command API Reference / Input / Output
</details> <details> <summary> PutPublicAccessBlock </summary>Command API Reference / Input / Output
</details> <details> <summary> RenameObject </summary>Command API Reference / Input / Output
</details> <details> <summary> RestoreObject </summary>Command API Reference / Input / Output
</details> <details> <summary> SelectObjectContent </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdateBucketMetadataAnnotationTableConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdateBucketMetadataInventoryTableConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdateBucketMetadataJournalTableConfiguration </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdateObjectEncryption </summary>Command API Reference / Input / Output
</details> <details> <summary> UploadPart </summary>Command API Reference / Input / Output
</details> <details> <summary> UploadPartCopy </summary> </details> <details> <summary> WriteGetObjectResponse </summary> </details>