

# Code examples for Amazon S3 using AWS SDKs
<a name="service_code_examples_s3"></a>

The following code examples show how to use Amazon S3 with an AWS software development kit (SDK). 

*Basics* are code examples that show you how to perform the essential operations within a service.

*Actions* are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

*Scenarios* are code examples that show you how to accomplish specific tasks by calling multiple functions within a service or combined with other AWS services.

For a complete list of AWS SDK developer guides and code examples, see [Developing with Amazon S3 using the AWS SDKs](sdk-general-information-section.md). This topic also includes information about getting started and details about previous SDK versions.

**Contents**
+ [Basics](service_code_examples_s3_basics.md)
  + [Hello Amazon S3](s3_example_s3_Hello_section.md)
  + [Learn the basics](s3_example_s3_Scenario_GettingStarted_section.md)
  + [Actions](service_code_examples_s3_actions.md)
    + [`AbortMultipartUpload`](s3_example_s3_AbortMultipartUpload_section.md)
    + [`CompleteMultipartUpload`](s3_example_s3_CompleteMultipartUpload_section.md)
    + [`CopyObject`](s3_example_s3_CopyObject_section.md)
    + [`CreateBucket`](s3_example_s3_CreateBucket_section.md)
    + [`CreateMultiRegionAccessPoint`](s3_example_s3_CreateMultiRegionAccessPoint_section.md)
    + [`CreateMultipartUpload`](s3_example_s3_CreateMultipartUpload_section.md)
    + [`CreatePresignedPost`](s3_example_s3_CreatePresignedPost_section.md)
    + [`DeleteBucket`](s3_example_s3_DeleteBucket_section.md)
    + [`DeleteBucketAnalyticsConfiguration`](s3_example_s3_DeleteBucketAnalyticsConfiguration_section.md)
    + [`DeleteBucketCors`](s3_example_s3_DeleteBucketCors_section.md)
    + [`DeleteBucketEncryption`](s3_example_s3_DeleteBucketEncryption_section.md)
    + [`DeleteBucketInventoryConfiguration`](s3_example_s3_DeleteBucketInventoryConfiguration_section.md)
    + [`DeleteBucketLifecycle`](s3_example_s3_DeleteBucketLifecycle_section.md)
    + [`DeleteBucketMetricsConfiguration`](s3_example_s3_DeleteBucketMetricsConfiguration_section.md)
    + [`DeleteBucketPolicy`](s3_example_s3_DeleteBucketPolicy_section.md)
    + [`DeleteBucketReplication`](s3_example_s3_DeleteBucketReplication_section.md)
    + [`DeleteBucketTagging`](s3_example_s3_DeleteBucketTagging_section.md)
    + [`DeleteBucketWebsite`](s3_example_s3_DeleteBucketWebsite_section.md)
    + [`DeleteObject`](s3_example_s3_DeleteObject_section.md)
    + [`DeleteObjectTagging`](s3_example_s3_DeleteObjectTagging_section.md)
    + [`DeleteObjects`](s3_example_s3_DeleteObjects_section.md)
    + [`DeletePublicAccessBlock`](s3_example_s3_DeletePublicAccessBlock_section.md)
    + [`GetBucketAccelerateConfiguration`](s3_example_s3_GetBucketAccelerateConfiguration_section.md)
    + [`GetBucketAcl`](s3_example_s3_GetBucketAcl_section.md)
    + [`GetBucketAnalyticsConfiguration`](s3_example_s3_GetBucketAnalyticsConfiguration_section.md)
    + [`GetBucketCors`](s3_example_s3_GetBucketCors_section.md)
    + [`GetBucketEncryption`](s3_example_s3_GetBucketEncryption_section.md)
    + [`GetBucketInventoryConfiguration`](s3_example_s3_GetBucketInventoryConfiguration_section.md)
    + [`GetBucketLifecycleConfiguration`](s3_example_s3_GetBucketLifecycleConfiguration_section.md)
    + [`GetBucketLocation`](s3_example_s3_GetBucketLocation_section.md)
    + [`GetBucketLogging`](s3_example_s3_GetBucketLogging_section.md)
    + [`GetBucketMetricsConfiguration`](s3_example_s3_GetBucketMetricsConfiguration_section.md)
    + [`GetBucketNotification`](s3_example_s3_GetBucketNotification_section.md)
    + [`GetBucketPolicy`](s3_example_s3_GetBucketPolicy_section.md)
    + [`GetBucketPolicyStatus`](s3_example_s3_GetBucketPolicyStatus_section.md)
    + [`GetBucketReplication`](s3_example_s3_GetBucketReplication_section.md)
    + [`GetBucketRequestPayment`](s3_example_s3_GetBucketRequestPayment_section.md)
    + [`GetBucketTagging`](s3_example_s3_GetBucketTagging_section.md)
    + [`GetBucketVersioning`](s3_example_s3_GetBucketVersioning_section.md)
    + [`GetBucketWebsite`](s3_example_s3_GetBucketWebsite_section.md)
    + [`GetObject`](s3_example_s3_GetObject_section.md)
    + [`GetObjectAcl`](s3_example_s3_GetObjectAcl_section.md)
    + [`GetObjectAttributes`](s3_example_s3_GetObjectAttributes_section.md)
    + [`GetObjectLegalHold`](s3_example_s3_GetObjectLegalHold_section.md)
    + [`GetObjectLockConfiguration`](s3_example_s3_GetObjectLockConfiguration_section.md)
    + [`GetObjectRetention`](s3_example_s3_GetObjectRetention_section.md)
    + [`GetObjectTagging`](s3_example_s3_GetObjectTagging_section.md)
    + [`GetPublicAccessBlock`](s3_example_s3_GetPublicAccessBlock_section.md)
    + [`HeadBucket`](s3_example_s3_HeadBucket_section.md)
    + [`HeadObject`](s3_example_s3_HeadObject_section.md)
    + [`ListBucketAnalyticsConfigurations`](s3_example_s3_ListBucketAnalyticsConfigurations_section.md)
    + [`ListBucketInventoryConfigurations`](s3_example_s3_ListBucketInventoryConfigurations_section.md)
    + [`ListBuckets`](s3_example_s3_ListBuckets_section.md)
    + [`ListMultipartUploads`](s3_example_s3_ListMultipartUploads_section.md)
    + [`ListObjectVersions`](s3_example_s3_ListObjectVersions_section.md)
    + [`ListObjects`](s3_example_s3_ListObjects_section.md)
    + [`ListObjectsV2`](s3_example_s3_ListObjectsV2_section.md)
    + [`PutBucketAccelerateConfiguration`](s3_example_s3_PutBucketAccelerateConfiguration_section.md)
    + [`PutBucketAcl`](s3_example_s3_PutBucketAcl_section.md)
    + [`PutBucketCors`](s3_example_s3_PutBucketCors_section.md)
    + [`PutBucketEncryption`](s3_example_s3_PutBucketEncryption_section.md)
    + [`PutBucketLifecycleConfiguration`](s3_example_s3_PutBucketLifecycleConfiguration_section.md)
    + [`PutBucketLogging`](s3_example_s3_PutBucketLogging_section.md)
    + [`PutBucketNotification`](s3_example_s3_PutBucketNotification_section.md)
    + [`PutBucketNotificationConfiguration`](s3_example_s3_PutBucketNotificationConfiguration_section.md)
    + [`PutBucketPolicy`](s3_example_s3_PutBucketPolicy_section.md)
    + [`PutBucketReplication`](s3_example_s3_PutBucketReplication_section.md)
    + [`PutBucketRequestPayment`](s3_example_s3_PutBucketRequestPayment_section.md)
    + [`PutBucketTagging`](s3_example_s3_PutBucketTagging_section.md)
    + [`PutBucketVersioning`](s3_example_s3_PutBucketVersioning_section.md)
    + [`PutBucketWebsite`](s3_example_s3_PutBucketWebsite_section.md)
    + [`PutObject`](s3_example_s3_PutObject_section.md)
    + [`PutObjectAcl`](s3_example_s3_PutObjectAcl_section.md)
    + [`PutObjectLegalHold`](s3_example_s3_PutObjectLegalHold_section.md)
    + [`PutObjectLockConfiguration`](s3_example_s3_PutObjectLockConfiguration_section.md)
    + [`PutObjectRetention`](s3_example_s3_PutObjectRetention_section.md)
    + [`RestoreObject`](s3_example_s3_RestoreObject_section.md)
    + [`SelectObjectContent`](s3_example_s3_SelectObjectContent_section.md)
    + [`UploadPart`](s3_example_s3_UploadPart_section.md)
    + [`UploadPartCopy`](s3_example_s3_UploadPartCopy_section.md)
+ [Scenarios](service_code_examples_s3_scenarios.md)
  + [Check if a bucket exists](s3_example_s3_Scenario_DoesBucketExist_section.md)
  + [Convert text to speech and back to text](s3_example_cross_Telephone_section.md)
  + [Create a presigned URL](s3_example_s3_Scenario_PresignedUrl_section.md)
  + [Create a serverless application to manage photos](s3_example_cross_PAM_section.md)
  + [Create a web page that lists Amazon S3 objects](s3_example_s3_Scenario_ListObjectsWeb_section.md)
  + [Create an Amazon Textract explorer application](s3_example_cross_TextractExplorer_section.md)
  + [Delete all objects in a bucket](s3_example_s3_Scenario_DeleteAllObjects_section.md)
  + [Delete incomplete multipart uploads](s3_example_s3_Scenario_AbortMultipartUpload_section.md)
  + [Detect PPE in images](s3_example_cross_RekognitionPhotoAnalyzerPPE_section.md)
  + [Detect entities in text extracted from an image](s3_example_cross_TextractComprehendDetectEntities_section.md)
  + [Detect faces in an image](s3_example_cross_DetectFaces_section.md)
  + [Detect objects in images](s3_example_cross_RekognitionPhotoAnalyzer_section.md)
  + [Detect people and objects in a video](s3_example_cross_RekognitionVideoDetection_section.md)
  + [Download S3 'directories'](s3_example_s3_Scenario_DownloadS3Directory_section.md)
  + [Download objects to a local directory](s3_example_s3_DownloadBucketToDirectory_section.md)
  + [Download stream of unknown size](s3_example_s3_Scenario_DownloadStream_section.md)
  + [Get an object from a Multi-Region Access Point](s3_example_s3_GetObject_MRAP_section.md)
  + [Get an object from a bucket if it has been modified](s3_example_s3_GetObject_IfModifiedSince_section.md)
  + [Get started with encryption](s3_example_s3_Encryption_section.md)
  + [Get started with tags](s3_example_s3_Scenario_Tagging_section.md)
  + [Getting started with Amazon Athena](s3_example_athena_GettingStarted_061_section.md)
  + [Getting started with Amazon EMR](s3_example_emr_GettingStarted_037_section.md)
  + [Getting started with Amazon S3](s3_example_s3_GettingStarted_section.md)
  + [Getting started with Amazon SageMaker Feature Store](s3_example_iam_GettingStarted_028_section.md)
  + [Getting started with Amazon Textract](s3_example_s3_GettingStarted_074_section.md)
  + [Getting started with Config](s3_example_config_service_GettingStarted_053_section.md)
  + [Lock Amazon S3 objects](s3_example_s3_Scenario_ObjectLock_section.md)
  + [Make conditional requests](s3_example_s3_Scenario_ConditionalRequests_section.md)
  + [Manage access control lists (ACLs)](s3_example_s3_Scenario_ManageACLs_section.md)
  + [Manage large messages using S3](s3_example_sqs_Scenario_SqsExtendedClient_section.md)
  + [Manage versioned objects in batches with a Lambda function](s3_example_s3_Scenario_BatchObjectVersioning_section.md)
  + [Parse URIs](s3_example_s3_Scenario_URIParsing_section.md)
  + [Perform a multipart copy](s3_example_s3_MultipartCopy_section.md)
  + [Process S3 event notifications](s3_example_s3_Scenario_ProcessS3EventNotification_section.md)
  + [Save EXIF and other image information](s3_example_cross_DetectLabels_section.md)
  + [Send event notifications to EventBridge](s3_example_s3_Scenario_PutBucketNotificationConfiguration_section.md)
  + [Track uploads and downloads](s3_example_s3_Scenario_TrackUploadDownload_section.md)
  + [Transform data with S3 Object Lambda](s3_example_cross_ServerlessS3DataTransformation_section.md)
  + [Unit and integration test with an SDK](s3_example_cross_Testing_section.md)
  + [Upload directory to a bucket](s3_example_s3_UploadDirectoryToBucket_section.md)
  + [Upload or download large files](s3_example_s3_Scenario_UsingLargeFiles_section.md)
  + [Upload stream of unknown size](s3_example_s3_Scenario_UploadStream_section.md)
  + [Use checksums](s3_example_s3_Scenario_UseChecksums_section.md)
  + [Work with Amazon S3 object integrity](s3_example_s3_Scenario_ObjectIntegrity_section.md)
  + [Work with versioned objects](s3_example_s3_Scenario_ObjectVersioningUsage_section.md)
+ [Serverless examples](service_code_examples_s3_serverless_examples.md)
  + [Invoke a Lambda function from an Amazon S3 trigger](s3_example_serverless_S3_Lambda_section.md)