or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

bucket-access-control.mdbucket-features.mdbucket-operations.mdclient-config.mdindex.mdlist-operations.mdmultipart-upload.mdobject-operations.mdpaginators-waiters.mdpresigned-urls.mdtypes.md
tile.json

index.mddocs/

AWS SDK for Go v2 - S3 Service

The AWS SDK for Go v2 S3 package provides a comprehensive, type-safe API client for Amazon Simple Storage Service (S3). This package enables Go applications to perform all S3 operations including object uploads/downloads, bucket management, multipart uploads, object tagging, versioning, lifecycle policies, encryption, access control, and advanced features like S3 Express One Zone and metadata tables.

Package Information

  • Package Name: github.com/aws/aws-sdk-go-v2/service/s3
  • Package Type: golang
  • Language: Go
  • Installation: go get github.com/aws/aws-sdk-go-v2/service/s3@v1.92.1
  • Import Path: github.com/aws/aws-sdk-go-v2/service/s3

Core Imports

import (
    "context"
    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/config"
    "github.com/aws/aws-sdk-go-v2/service/s3"
    "github.com/aws/aws-sdk-go-v2/service/s3/types"
)

Basic Usage

package main

import (
    "context"
    "fmt"
    "bytes"

    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/config"
    "github.com/aws/aws-sdk-go-v2/service/s3"
)

func main() {
    // Load AWS configuration
    cfg, err := config.LoadDefaultConfig(context.TODO())
    if err != nil {
        panic(err)
    }

    // Create S3 client
    client := s3.NewFromConfig(cfg)

    // Upload an object
    _, err = client.PutObject(context.TODO(), &s3.PutObjectInput{
        Bucket: aws.String("my-bucket"),
        Key:    aws.String("my-object.txt"),
        Body:   bytes.NewReader([]byte("Hello, S3!")),
    })
    if err != nil {
        panic(err)
    }

    // Download an object
    result, err := client.GetObject(context.TODO(), &s3.GetObjectInput{
        Bucket: aws.String("my-bucket"),
        Key:    aws.String("my-object.txt"),
    })
    if err != nil {
        panic(err)
    }
    defer result.Body.Close()

    fmt.Println("Object downloaded successfully")
}

Architecture

The S3 SDK is organized into several key components:

  • Client: The main s3.Client type that provides methods for all S3 operations
  • Operations: 107 operation methods covering all S3 functionality
  • Types Package: Complete type definitions for inputs, outputs, enums, and data structures
  • Paginators: Automatic pagination for list operations
  • Waiters: Poll operations until desired state is reached
  • Presigned URLs: Generate time-limited URLs for browser/external access
  • Middleware: Extensible middleware stack for customization

Capabilities

Client Configuration and Setup

Initialize and configure the S3 client with various options including credentials, region, endpoint customization, retry behavior, and S3-specific features like transfer acceleration and path-style addressing.

Key APIs:

func New(options Options, optFns ...func(*Options)) *Client
func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client

See Client Configuration for complete details.

Object Operations

Perform all object-level operations including uploading, downloading, copying, deleting objects, managing object metadata, tags, ACLs, retention, and legal holds.

Key APIs:

func (c *Client) PutObject(ctx context.Context, params *PutObjectInput, optFns ...func(*Options)) (*PutObjectOutput, error)
func (c *Client) GetObject(ctx context.Context, params *GetObjectInput, optFns ...func(*Options)) (*GetObjectOutput, error)
func (c *Client) DeleteObject(ctx context.Context, params *DeleteObjectInput, optFns ...func(*Options)) (*DeleteObjectOutput, error)
func (c *Client) CopyObject(ctx context.Context, params *CopyObjectInput, optFns ...func(*Options)) (*CopyObjectOutput, error)
func (c *Client) HeadObject(ctx context.Context, params *HeadObjectInput, optFns ...func(*Options)) (*HeadObjectOutput, error)

Total Operations: 23 object operations

See Object Operations for complete details.

Multipart Upload Operations

Manage multipart uploads for large objects, including initiating uploads, uploading parts, completing uploads, listing uploads and parts, and aborting incomplete uploads.

Key APIs:

func (c *Client) CreateMultipartUpload(ctx context.Context, params *CreateMultipartUploadInput, optFns ...func(*Options)) (*CreateMultipartUploadOutput, error)
func (c *Client) UploadPart(ctx context.Context, params *UploadPartInput, optFns ...func(*Options)) (*UploadPartOutput, error)
func (c *Client) CompleteMultipartUpload(ctx context.Context, params *CompleteMultipartUploadInput, optFns ...func(*Options)) (*CompleteMultipartUploadOutput, error)
func (c *Client) AbortMultipartUpload(ctx context.Context, params *AbortMultipartUploadInput, optFns ...func(*Options)) (*AbortMultipartUploadOutput, error)

Total Operations: 7 multipart operations

See Multipart Upload Operations for complete details.

List Operations

List objects, object versions, multipart uploads, and parts with support for pagination, filtering by prefix and delimiter, and continuation tokens.

Key APIs:

func (c *Client) ListObjectsV2(ctx context.Context, params *ListObjectsV2Input, optFns ...func(*Options)) (*ListObjectsV2Output, error)
func (c *Client) ListObjectVersions(ctx context.Context, params *ListObjectVersionsInput, optFns ...func(*Options)) (*ListObjectVersionsOutput, error)

Total Operations: 4 list operations with paginator support

See List Operations for complete details.

Bucket Operations

Create, delete, and manage buckets including checking bucket existence, listing all buckets, and getting bucket location and metadata.

Key APIs:

func (c *Client) CreateBucket(ctx context.Context, params *CreateBucketInput, optFns ...func(*Options)) (*CreateBucketOutput, error)
func (c *Client) DeleteBucket(ctx context.Context, params *DeleteBucketInput, optFns ...func(*Options)) (*DeleteBucketOutput, error)
func (c *Client) HeadBucket(ctx context.Context, params *HeadBucketInput, optFns ...func(*Options)) (*HeadBucketOutput, error)
func (c *Client) ListBuckets(ctx context.Context, params *ListBucketsInput, optFns ...func(*Options)) (*ListBucketsOutput, error)

Total Operations: 8 bucket operations

See Bucket Operations for complete details.

Bucket Access Control

Manage bucket and object access control through ACLs, bucket policies, ABAC (attribute-based access control), public access block configuration, and ownership controls.

Key APIs:

func (c *Client) PutBucketPolicy(ctx context.Context, params *PutBucketPolicyInput, optFns ...func(*Options)) (*PutBucketPolicyOutput, error)
func (c *Client) GetBucketAcl(ctx context.Context, params *GetBucketAclInput, optFns ...func(*Options)) (*GetBucketAclOutput, error)
func (c *Client) PutPublicAccessBlock(ctx context.Context, params *PutPublicAccessBlockInput, optFns ...func(*Options)) (*PutPublicAccessBlockOutput, error)

Total Operations: 15 access control operations

See Bucket Access Control for complete details.

Bucket Features and Configuration

Configure advanced bucket features including versioning, tagging, CORS, encryption, lifecycle rules, replication, notifications, website hosting, logging, request payment, transfer acceleration, analytics, metrics, inventory, and intelligent-tiering.

Key APIs:

func (c *Client) PutBucketVersioning(ctx context.Context, params *PutBucketVersioningInput, optFns ...func(*Options)) (*PutBucketVersioningOutput, error)
func (c *Client) PutBucketEncryption(ctx context.Context, params *PutBucketEncryptionInput, optFns ...func(*Options)) (*PutBucketEncryptionOutput, error)
func (c *Client) PutBucketLifecycleConfiguration(ctx context.Context, params *PutBucketLifecycleConfigurationInput, optFns ...func(*Options)) (*PutBucketLifecycleConfigurationOutput, error)
func (c *Client) PutBucketReplication(ctx context.Context, params *PutBucketReplicationInput, optFns ...func(*Options)) (*PutBucketReplicationOutput, error)

Total Operations: 52 configuration operations

See Bucket Features and Configuration for complete details.

Presigned URLs

Generate presigned URLs for temporary, time-limited access to S3 operations without requiring AWS credentials, supporting both GET and POST methods.

Key APIs:

func NewPresignClient(c *Client, optFns ...func(*PresignOptions)) *PresignClient
func (c *PresignClient) PresignGetObject(ctx context.Context, params *GetObjectInput, optFns ...func(*PresignOptions)) (*v4.PresignedHTTPRequest, error)
func (c *PresignClient) PresignPutObject(ctx context.Context, params *PutObjectInput, optFns ...func(*PresignOptions)) (*v4.PresignedHTTPRequest, error)

Total Methods: 5 presign methods + POST upload support

See Presigned URLs for complete details.

Paginators and Waiters

Use paginators for automatic pagination of list operations and waiters to poll operations until a desired state is reached.

Key APIs:

func NewListObjectsV2Paginator(client ListObjectsV2APIClient, params *ListObjectsV2Input, optFns ...func(*ListObjectsV2PaginatorOptions)) *ListObjectsV2Paginator
func NewBucketExistsWaiter(client HeadBucketAPIClient, optFns ...func(*BucketExistsWaiterOptions)) *BucketExistsWaiter

Total: 6 paginators, 2 waiters

See Paginators and Waiters for complete details.

Types and Data Structures

The types package contains 257 exported types including enumerations, data structures for inputs/outputs, configuration objects, and error types.

Key Types:

type StorageClass string
type ServerSideEncryption string
type ObjectIdentifier struct
type Tag struct
type Grant struct
type LifecycleRule struct
type ReplicationRule struct

See Types Reference for complete type definitions.

Constants

const ServiceID = "S3"
const ServiceAPIVersion = "2006-03-01"

Error Handling

All operations return an error as the second return value. Common S3 errors from the types package include:

  • NoSuchBucket - Bucket does not exist
  • NoSuchKey - Object key does not exist
  • BucketAlreadyExists - Bucket name already taken
  • NoSuchUpload - Multipart upload does not exist
  • InvalidObjectState - Object is in invalid state for operation

Features

  • Complete S3 API Coverage: All 107 S3 operations
  • Type Safety: Full Go type definitions for all inputs, outputs, and configurations
  • Context Support: All operations accept context for cancellation and timeouts
  • Automatic Retries: Built-in retry logic with configurable strategies
  • Multipart Upload Support: Efficient large object uploads
  • Presigned URLs: Generate temporary access URLs
  • Pagination: Automatic continuation for list operations
  • Waiters: Poll until desired state is reached
  • Checksums: Support for CRC32, CRC32C, SHA1, SHA256 validation
  • S3 Express One Zone: Support for directory buckets and sessions
  • S3 on Outposts: Full Outposts integration
  • Multi-Region Access Points: MRAP support
  • Transfer Acceleration: Accelerated transfers via CloudFront
  • Virtual-Hosted and Path-Style: Both addressing modes supported
  • SigV4 and SigV4A: AWS signature version 4 and multi-region signing

Additional Resources

  • AWS Documentation: https://docs.aws.amazon.com/s3/
  • Package Documentation: https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/s3
  • AWS SDK for Go v2: https://github.com/aws/aws-sdk-go-v2