s3

package
v0.0.1-alpha.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package s3 implements the AWS S3 REST API emulator.

S3 uses a REST-style XML API. Each HTTP method+path combination maps to an AWS S3 operation. Sub-resource query parameters (e.g. ?acl, ?cors, ?policy) further specialise the operation. Each sub-resource routes to its own named handler in handler.go, which either implements the operation or returns a clear HTTP 501 with x-emulator-unsupported: true.

Implemented:

GET  /                           → ListBuckets
PUT  /{bucket}                   → CreateBucket
HEAD /{bucket}                   → HeadBucket
DELETE /{bucket}                 → DeleteBucket
GET  /{bucket}?location          → GetBucketLocation
GET  /{bucket}?list-type=2       → ListObjectsV2
PUT  /{bucket}/{key}             → PutObject
PUT  /{bucket}/{key} (+copy hdr) → CopyObject
GET  /{bucket}/{key}             → GetObject
HEAD /{bucket}/{key}             → HeadObject
DELETE /{bucket}/{key}           → DeleteObject

All other operations are routed to named stubs that return HTTP 501. See docs/services/s3.md for the full support matrix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Name             string                `json:"name"`
	Region           string                `json:"region"`
	CreationDate     time.Time             `json:"creation_date"`
	VersioningStatus string                `json:"versioning_status,omitempty"` // "Enabled", "Suspended", or ""
	Tags             map[string]string     `json:"tags,omitempty"`
	WebsiteConfig    *WebsiteConfiguration `json:"website_config,omitempty"`
	CORSRules        []CORSRule            `json:"cors_rules,omitempty"`
	Policy           string                `json:"policy,omitempty"`
}

Bucket represents a stored S3 bucket.

type CORSRule

type CORSRule struct {
	AllowedHeaders []string `json:"allowed_headers,omitempty"`
	AllowedMethods []string `json:"allowed_methods"`
	AllowedOrigins []string `json:"allowed_origins"`
	ExposeHeaders  []string `json:"expose_headers,omitempty"`
	MaxAgeSeconds  int      `json:"max_age_seconds,omitempty"`
}

CORSRule stores a single CORS rule for an S3 bucket.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler holds the dependencies for S3 HTTP handlers. All handler methods hang off this struct — this is the standard Go pattern for grouping related handlers (equivalent to a TypeScript class with methods).

func (*Handler) AbortMultipartUpload

func (h *Handler) AbortMultipartUpload(w http.ResponseWriter, r *http.Request)

AbortMultipartUpload handles DELETE /{bucket}/{key}?uploadId=xxx AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html

func (*Handler) BucketDelete

func (h *Handler) BucketDelete(w http.ResponseWriter, r *http.Request)

BucketDelete dispatches DELETE /{bucket} by sub-resource query param.

func (*Handler) BucketGet

func (h *Handler) BucketGet(w http.ResponseWriter, r *http.Request)

BucketGet dispatches GET /{bucket} by sub-resource query param.

func (*Handler) BucketPost

func (h *Handler) BucketPost(w http.ResponseWriter, r *http.Request)

BucketPost dispatches POST /{bucket} by sub-resource query param.

func (*Handler) BucketPut

func (h *Handler) BucketPut(w http.ResponseWriter, r *http.Request)

BucketPut dispatches PUT /{bucket} by sub-resource query param.

func (*Handler) CompleteMultipartUpload

func (h *Handler) CompleteMultipartUpload(w http.ResponseWriter, r *http.Request)

CompleteMultipartUpload handles POST /{bucket}/{key}?uploadId=xxx AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html

func (*Handler) CopyObject

func (h *Handler) CopyObject(w http.ResponseWriter, r *http.Request)

CopyObject handles PUT /{bucket}/{key} with x-amz-copy-source header. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html

func (*Handler) CreateBucket

func (h *Handler) CreateBucket(w http.ResponseWriter, r *http.Request)

CreateBucket handles PUT /{bucket} AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html

func (*Handler) CreateBucketMetadataConfiguration

func (h *Handler) CreateBucketMetadataConfiguration(w http.ResponseWriter, r *http.Request)

CreateBucketMetadataConfiguration handles PUT /{bucket}?metadata AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucketMetadataConfiguration.html

func (*Handler) CreateBucketMetadataTableConfiguration

func (h *Handler) CreateBucketMetadataTableConfiguration(w http.ResponseWriter, r *http.Request)

CreateBucketMetadataTableConfiguration handles POST /{bucket}?metadataTable AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucketMetadataTableConfiguration.html

func (*Handler) CreateMultipartUpload

func (h *Handler) CreateMultipartUpload(w http.ResponseWriter, r *http.Request)

CreateMultipartUpload handles POST /{bucket}/{key}?uploads AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html

func (*Handler) CreateSession

func (h *Handler) CreateSession(w http.ResponseWriter, r *http.Request)

CreateSession handles GET /{bucket}?session AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateSession.html

func (*Handler) DeleteBucket

func (h *Handler) DeleteBucket(w http.ResponseWriter, r *http.Request)

DeleteBucket handles DELETE /{bucket} AWS requires the bucket to be empty before deletion.

func (*Handler) DeleteBucketAnalyticsConfiguration

func (h *Handler) DeleteBucketAnalyticsConfiguration(w http.ResponseWriter, r *http.Request)

DeleteBucketAnalyticsConfiguration handles DELETE /{bucket}?analytics AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketAnalyticsConfiguration.html

func (*Handler) DeleteBucketCors

func (h *Handler) DeleteBucketCors(w http.ResponseWriter, r *http.Request)

DeleteBucketCors handles DELETE /{bucket}?cors AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketCors.html

func (*Handler) DeleteBucketEncryption

func (h *Handler) DeleteBucketEncryption(w http.ResponseWriter, r *http.Request)

DeleteBucketEncryption handles DELETE /{bucket}?encryption AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketEncryption.html

func (*Handler) DeleteBucketIntelligentTieringConfiguration

func (h *Handler) DeleteBucketIntelligentTieringConfiguration(w http.ResponseWriter, r *http.Request)

DeleteBucketIntelligentTieringConfiguration handles DELETE /{bucket}?intelligent-tiering AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketIntelligentTieringConfiguration.html

func (*Handler) DeleteBucketInventoryConfiguration

func (h *Handler) DeleteBucketInventoryConfiguration(w http.ResponseWriter, r *http.Request)

DeleteBucketInventoryConfiguration handles DELETE /{bucket}?inventory AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketInventoryConfiguration.html

func (*Handler) DeleteBucketLifecycle

func (h *Handler) DeleteBucketLifecycle(w http.ResponseWriter, r *http.Request)

DeleteBucketLifecycle handles DELETE /{bucket}?lifecycle AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketLifecycle.html

func (*Handler) DeleteBucketMetadataConfiguration

func (h *Handler) DeleteBucketMetadataConfiguration(w http.ResponseWriter, r *http.Request)

DeleteBucketMetadataConfiguration handles DELETE /{bucket}?metadata AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketMetadataConfiguration.html

func (*Handler) DeleteBucketMetadataTableConfiguration

func (h *Handler) DeleteBucketMetadataTableConfiguration(w http.ResponseWriter, r *http.Request)

DeleteBucketMetadataTableConfiguration handles DELETE /{bucket}?metadataTable AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketMetadataTableConfiguration.html

func (*Handler) DeleteBucketMetricsConfiguration

func (h *Handler) DeleteBucketMetricsConfiguration(w http.ResponseWriter, r *http.Request)

DeleteBucketMetricsConfiguration handles DELETE /{bucket}?metrics AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketMetricsConfiguration.html

func (*Handler) DeleteBucketOwnershipControls

func (h *Handler) DeleteBucketOwnershipControls(w http.ResponseWriter, r *http.Request)

DeleteBucketOwnershipControls handles DELETE /{bucket}?ownershipControls AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketOwnershipControls.html

func (*Handler) DeleteBucketPolicy

func (h *Handler) DeleteBucketPolicy(w http.ResponseWriter, r *http.Request)

DeleteBucketPolicy handles DELETE /{bucket}?policy AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketPolicy.html

func (*Handler) DeleteBucketReplication

func (h *Handler) DeleteBucketReplication(w http.ResponseWriter, r *http.Request)

DeleteBucketReplication handles DELETE /{bucket}?replication AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketReplication.html

func (*Handler) DeleteBucketTagging

func (h *Handler) DeleteBucketTagging(w http.ResponseWriter, r *http.Request)

DeleteBucketTagging handles DELETE /{bucket}?tagging.

func (*Handler) DeleteBucketWebsite

func (h *Handler) DeleteBucketWebsite(w http.ResponseWriter, r *http.Request)

DeleteBucketWebsite handles DELETE /{bucket}?website AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketWebsite.html

func (*Handler) DeleteObject

func (h *Handler) DeleteObject(w http.ResponseWriter, r *http.Request)

DeleteObject handles DELETE /{bucket}/{key}. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html

func (*Handler) DeleteObjectTagging

func (h *Handler) DeleteObjectTagging(w http.ResponseWriter, r *http.Request)

DeleteObjectTagging handles DELETE /{bucket}/{key}?tagging.

func (*Handler) DeleteObjects

func (h *Handler) DeleteObjects(w http.ResponseWriter, r *http.Request)

DeleteObjects handles POST /{bucket}?delete — batch delete up to 1000 keys. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html

func (*Handler) DeletePublicAccessBlock

func (h *Handler) DeletePublicAccessBlock(w http.ResponseWriter, r *http.Request)

DeletePublicAccessBlock handles DELETE /{bucket}?publicAccessBlock AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeletePublicAccessBlock.html

func (*Handler) GetBucketAbac

func (h *Handler) GetBucketAbac(w http.ResponseWriter, r *http.Request)

GetBucketAbac handles GET /{bucket}?abac AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAbac.html

func (*Handler) GetBucketAccelerateConfiguration

func (h *Handler) GetBucketAccelerateConfiguration(w http.ResponseWriter, r *http.Request)

GetBucketAccelerateConfiguration handles GET /{bucket}?accelerate AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAccelerateConfiguration.html

func (*Handler) GetBucketAcl

func (h *Handler) GetBucketAcl(w http.ResponseWriter, r *http.Request)

GetBucketAcl handles GET /{bucket}?acl AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAcl.html

func (*Handler) GetBucketCors

func (h *Handler) GetBucketCors(w http.ResponseWriter, r *http.Request)

GetBucketCors handles GET /{bucket}?cors AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketCors.html Implemented in handler_bucket.go.

func (*Handler) GetBucketEncryption

func (h *Handler) GetBucketEncryption(w http.ResponseWriter, r *http.Request)

GetBucketEncryption handles GET /{bucket}?encryption AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketEncryption.html

func (*Handler) GetBucketLifecycleConfiguration

func (h *Handler) GetBucketLifecycleConfiguration(w http.ResponseWriter, r *http.Request)

GetBucketLifecycleConfiguration handles GET /{bucket}?lifecycle Covers both GetBucketLifecycle (deprecated) and GetBucketLifecycleConfiguration. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycleConfiguration.html

func (*Handler) GetBucketLocation

func (h *Handler) GetBucketLocation(w http.ResponseWriter, r *http.Request)

GetBucketLocation handles GET /{bucket}?location. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLocation.html

func (*Handler) GetBucketLogging

func (h *Handler) GetBucketLogging(w http.ResponseWriter, r *http.Request)

GetBucketLogging handles GET /{bucket}?logging AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLogging.html

func (*Handler) GetBucketMetadataConfiguration

func (h *Handler) GetBucketMetadataConfiguration(w http.ResponseWriter, r *http.Request)

GetBucketMetadataConfiguration handles GET /{bucket}?metadata AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketMetadataConfiguration.html

func (*Handler) GetBucketMetadataTableConfiguration

func (h *Handler) GetBucketMetadataTableConfiguration(w http.ResponseWriter, r *http.Request)

GetBucketMetadataTableConfiguration handles GET /{bucket}?metadataTable AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketMetadataTableConfiguration.html

func (*Handler) GetBucketNotificationConfiguration

func (h *Handler) GetBucketNotificationConfiguration(w http.ResponseWriter, r *http.Request)

GetBucketNotificationConfiguration handles GET /{bucket}?notification.

func (*Handler) GetBucketOwnershipControls

func (h *Handler) GetBucketOwnershipControls(w http.ResponseWriter, r *http.Request)

GetBucketOwnershipControls handles GET /{bucket}?ownershipControls AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketOwnershipControls.html

func (*Handler) GetBucketPolicy

func (h *Handler) GetBucketPolicy(w http.ResponseWriter, r *http.Request)

GetBucketPolicy handles GET /{bucket}?policy AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketPolicy.html

func (*Handler) GetBucketPolicyStatus

func (h *Handler) GetBucketPolicyStatus(w http.ResponseWriter, r *http.Request)

GetBucketPolicyStatus handles GET /{bucket}?policyStatus AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketPolicyStatus.html

func (*Handler) GetBucketReplication

func (h *Handler) GetBucketReplication(w http.ResponseWriter, r *http.Request)

GetBucketReplication handles GET /{bucket}?replication AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketReplication.html

func (*Handler) GetBucketRequestPayment

func (h *Handler) GetBucketRequestPayment(w http.ResponseWriter, r *http.Request)

GetBucketRequestPayment handles GET /{bucket}?requestPayment AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketRequestPayment.html

func (*Handler) GetBucketTagging

func (h *Handler) GetBucketTagging(w http.ResponseWriter, r *http.Request)

GetBucketTagging handles GET /{bucket}?tagging.

func (*Handler) GetBucketVersioning

func (h *Handler) GetBucketVersioning(w http.ResponseWriter, r *http.Request)

GetBucketVersioning handles GET /{bucket}?versioning. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketVersioning.html

func (*Handler) GetBucketWebsite

func (h *Handler) GetBucketWebsite(w http.ResponseWriter, r *http.Request)

GetBucketWebsite handles GET /{bucket}?website AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketWebsite.html Implemented in handler_bucket.go.

func (*Handler) GetObject

func (h *Handler) GetObject(w http.ResponseWriter, r *http.Request)

GetObject handles GET /{bucket}/{key}. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html

func (*Handler) GetObjectAcl

func (h *Handler) GetObjectAcl(w http.ResponseWriter, r *http.Request)

GetObjectAcl handles GET /{bucket}/{key}?acl AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAcl.html

func (*Handler) GetObjectAttributes

func (h *Handler) GetObjectAttributes(w http.ResponseWriter, r *http.Request)

GetObjectAttributes handles GET /{bucket}/{key}?attributes AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAttributes.html

func (*Handler) GetObjectLegalHold

func (h *Handler) GetObjectLegalHold(w http.ResponseWriter, r *http.Request)

GetObjectLegalHold handles GET /{bucket}/{key}?legal-hold AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectLegalHold.html

func (*Handler) GetObjectLockConfiguration

func (h *Handler) GetObjectLockConfiguration(w http.ResponseWriter, r *http.Request)

GetObjectLockConfiguration handles GET /{bucket}?object-lock AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectLockConfiguration.html

func (*Handler) GetObjectRetention

func (h *Handler) GetObjectRetention(w http.ResponseWriter, r *http.Request)

GetObjectRetention handles GET /{bucket}/{key}?retention AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectRetention.html

func (*Handler) GetObjectTagging

func (h *Handler) GetObjectTagging(w http.ResponseWriter, r *http.Request)

GetObjectTagging handles GET /{bucket}/{key}?tagging.

func (*Handler) GetObjectTorrent

func (h *Handler) GetObjectTorrent(w http.ResponseWriter, r *http.Request)

GetObjectTorrent handles GET /{bucket}/{key}?torrent AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTorrent.html

func (*Handler) GetPublicAccessBlock

func (h *Handler) GetPublicAccessBlock(w http.ResponseWriter, r *http.Request)

GetPublicAccessBlock handles GET /{bucket}?publicAccessBlock AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetPublicAccessBlock.html

func (*Handler) HeadBucket

func (h *Handler) HeadBucket(w http.ResponseWriter, r *http.Request)

HeadBucket handles HEAD /{bucket} Returns 200 if the bucket exists, 404 if not.

func (*Handler) HeadObject

func (h *Handler) HeadObject(w http.ResponseWriter, r *http.Request)

HeadObject handles HEAD /{bucket}/{key} Returns the same headers as GetObject but no body. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html

func (*Handler) ListBucketAnalyticsConfigurations

func (h *Handler) ListBucketAnalyticsConfigurations(w http.ResponseWriter, r *http.Request)

ListBucketAnalyticsConfigurations handles GET /{bucket}?analytics AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketAnalyticsConfigurations.html

func (*Handler) ListBucketIntelligentTieringConfigurations

func (h *Handler) ListBucketIntelligentTieringConfigurations(w http.ResponseWriter, r *http.Request)

ListBucketIntelligentTieringConfigurations handles GET /{bucket}?intelligent-tiering AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketIntelligentTieringConfigurations.html

func (*Handler) ListBucketInventoryConfigurations

func (h *Handler) ListBucketInventoryConfigurations(w http.ResponseWriter, r *http.Request)

ListBucketInventoryConfigurations handles GET /{bucket}?inventory AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketInventoryConfigurations.html

func (*Handler) ListBucketMetricsConfigurations

func (h *Handler) ListBucketMetricsConfigurations(w http.ResponseWriter, r *http.Request)

ListBucketMetricsConfigurations handles GET /{bucket}?metrics AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketMetricsConfigurations.html

func (*Handler) ListBuckets

func (h *Handler) ListBuckets(w http.ResponseWriter, r *http.Request)

ListBuckets handles GET / — list all buckets owned by the account. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html

func (*Handler) ListDirectoryBuckets

func (h *Handler) ListDirectoryBuckets(w http.ResponseWriter, r *http.Request)

ListDirectoryBuckets handles GET /?directory-buckets AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListDirectoryBuckets.html

func (*Handler) ListMultipartUploads

func (h *Handler) ListMultipartUploads(w http.ResponseWriter, r *http.Request)

ListMultipartUploads handles GET /{bucket}?uploads AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html

func (*Handler) ListObjectVersions

func (h *Handler) ListObjectVersions(w http.ResponseWriter, r *http.Request)

ListObjectVersions handles GET /{bucket}?versions. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectVersions.html

The store does not support true multi-versioning: each key has exactly one live object stored. So every object is returned as a Version entry with VersionId="null" and IsLatest=true. This satisfies the AWS SDK cleanup pattern (ListObjectVersions → DeleteObjects) without requiring a full versioning store redesign.

func (*Handler) ListObjects

func (h *Handler) ListObjects(w http.ResponseWriter, r *http.Request)

ListObjects handles GET /{bucket} (legacy v1 listing, no list-type param). AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html

Implemented in handler_bucket.go as ListObjectsV1.

func (*Handler) ListObjectsV1

func (h *Handler) ListObjectsV1(w http.ResponseWriter, r *http.Request)

ListObjectsV1 handles GET /{bucket} (no list-type) and GET /{bucket}?list-type=1. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html

func (*Handler) ListObjectsV2

func (h *Handler) ListObjectsV2(w http.ResponseWriter, r *http.Request)

ListObjectsV2 handles GET /{bucket}?list-type=2. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html

func (*Handler) ListObjectsV2OrLocation deprecated

func (h *Handler) ListObjectsV2OrLocation(w http.ResponseWriter, r *http.Request)

ListObjectsV2OrLocation dispatches GET /{bucket} based on query parameters: ?list-type=2 → ListObjectsV2 ?location → GetBucketLocation (no params) → ListObjectsV2 (default)

Deprecated: use BucketGet which handles all S3 bucket-level query params.

func (*Handler) ListParts

func (h *Handler) ListParts(w http.ResponseWriter, r *http.Request)

ListParts handles GET /{bucket}/{key}?uploadId=xxx AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html

func (*Handler) ObjectDelete

func (h *Handler) ObjectDelete(w http.ResponseWriter, r *http.Request)

ObjectDelete dispatches DELETE /{bucket}/{key} by sub-resource query param.

func (*Handler) ObjectGet

func (h *Handler) ObjectGet(w http.ResponseWriter, r *http.Request)

ObjectGet dispatches GET /{bucket}/{key} by sub-resource query param.

func (*Handler) ObjectPost

func (h *Handler) ObjectPost(w http.ResponseWriter, r *http.Request)

ObjectPost dispatches POST /{bucket}/{key} by sub-resource query param.

func (*Handler) PutBucketAbac

func (h *Handler) PutBucketAbac(w http.ResponseWriter, r *http.Request)

PutBucketAbac handles PUT /{bucket}?abac AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAbac.html

func (*Handler) PutBucketAccelerateConfiguration

func (h *Handler) PutBucketAccelerateConfiguration(w http.ResponseWriter, r *http.Request)

PutBucketAccelerateConfiguration handles PUT /{bucket}?accelerate AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAccelerateConfiguration.html

func (*Handler) PutBucketAcl

func (h *Handler) PutBucketAcl(w http.ResponseWriter, r *http.Request)

PutBucketAcl handles PUT /{bucket}?acl AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAcl.html

func (*Handler) PutBucketAnalyticsConfiguration

func (h *Handler) PutBucketAnalyticsConfiguration(w http.ResponseWriter, r *http.Request)

PutBucketAnalyticsConfiguration handles PUT /{bucket}?analytics AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAnalyticsConfiguration.html

func (*Handler) PutBucketCors

func (h *Handler) PutBucketCors(w http.ResponseWriter, r *http.Request)

PutBucketCors handles PUT /{bucket}?cors AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketCors.html Implemented in handler_bucket.go.

func (*Handler) PutBucketEncryption

func (h *Handler) PutBucketEncryption(w http.ResponseWriter, r *http.Request)

PutBucketEncryption handles PUT /{bucket}?encryption AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketEncryption.html

func (*Handler) PutBucketIntelligentTieringConfiguration

func (h *Handler) PutBucketIntelligentTieringConfiguration(w http.ResponseWriter, r *http.Request)

PutBucketIntelligentTieringConfiguration handles PUT /{bucket}?intelligent-tiering AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketIntelligentTieringConfiguration.html

func (*Handler) PutBucketInventoryConfiguration

func (h *Handler) PutBucketInventoryConfiguration(w http.ResponseWriter, r *http.Request)

PutBucketInventoryConfiguration handles PUT /{bucket}?inventory AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketInventoryConfiguration.html

func (*Handler) PutBucketLifecycleConfiguration

func (h *Handler) PutBucketLifecycleConfiguration(w http.ResponseWriter, r *http.Request)

PutBucketLifecycleConfiguration handles PUT /{bucket}?lifecycle Covers both PutBucketLifecycle (deprecated) and PutBucketLifecycleConfiguration. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycleConfiguration.html

func (*Handler) PutBucketLogging

func (h *Handler) PutBucketLogging(w http.ResponseWriter, r *http.Request)

PutBucketLogging handles PUT /{bucket}?logging AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLogging.html

func (*Handler) PutBucketMetricsConfiguration

func (h *Handler) PutBucketMetricsConfiguration(w http.ResponseWriter, r *http.Request)

PutBucketMetricsConfiguration handles PUT /{bucket}?metrics AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketMetricsConfiguration.html

func (*Handler) PutBucketNotificationConfiguration

func (h *Handler) PutBucketNotificationConfiguration(w http.ResponseWriter, r *http.Request)

PutBucketNotificationConfiguration handles PUT /{bucket}?notification.

func (*Handler) PutBucketOwnershipControls

func (h *Handler) PutBucketOwnershipControls(w http.ResponseWriter, r *http.Request)

PutBucketOwnershipControls handles PUT /{bucket}?ownershipControls AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketOwnershipControls.html

func (*Handler) PutBucketPolicy

func (h *Handler) PutBucketPolicy(w http.ResponseWriter, r *http.Request)

PutBucketPolicy handles PUT /{bucket}?policy AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketPolicy.html

func (*Handler) PutBucketReplication

func (h *Handler) PutBucketReplication(w http.ResponseWriter, r *http.Request)

PutBucketReplication handles PUT /{bucket}?replication AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketReplication.html

func (*Handler) PutBucketRequestPayment

func (h *Handler) PutBucketRequestPayment(w http.ResponseWriter, r *http.Request)

PutBucketRequestPayment handles PUT /{bucket}?requestPayment AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketRequestPayment.html

func (*Handler) PutBucketTagging

func (h *Handler) PutBucketTagging(w http.ResponseWriter, r *http.Request)

PutBucketTagging handles PUT /{bucket}?tagging.

func (*Handler) PutBucketVersioning

func (h *Handler) PutBucketVersioning(w http.ResponseWriter, r *http.Request)

PutBucketVersioning handles PUT /{bucket}?versioning. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketVersioning.html

func (*Handler) PutBucketWebsite

func (h *Handler) PutBucketWebsite(w http.ResponseWriter, r *http.Request)

PutBucketWebsite handles PUT /{bucket}?website AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketWebsite.html Implemented in handler_bucket.go.

func (*Handler) PutObject

func (h *Handler) PutObject(w http.ResponseWriter, r *http.Request)

PutObject handles PUT /{bucket}/{key}. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html

func (*Handler) PutObjectAcl

func (h *Handler) PutObjectAcl(w http.ResponseWriter, r *http.Request)

PutObjectAcl handles PUT /{bucket}/{key}?acl AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectAcl.html

func (*Handler) PutObjectLegalHold

func (h *Handler) PutObjectLegalHold(w http.ResponseWriter, r *http.Request)

PutObjectLegalHold handles PUT /{bucket}/{key}?legal-hold AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectLegalHold.html

func (*Handler) PutObjectLockConfiguration

func (h *Handler) PutObjectLockConfiguration(w http.ResponseWriter, r *http.Request)

PutObjectLockConfiguration handles PUT /{bucket}?object-lock AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectLockConfiguration.html

func (*Handler) PutObjectOrCopy

func (h *Handler) PutObjectOrCopy(w http.ResponseWriter, r *http.Request)

PutObjectOrCopy dispatches PUT /{bucket}/{key}. partNumber is checked first because it requires a secondary header discriminant that the route table can't express. All other sub-resources use the table.

func (*Handler) PutObjectRetention

func (h *Handler) PutObjectRetention(w http.ResponseWriter, r *http.Request)

PutObjectRetention handles PUT /{bucket}/{key}?retention AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectRetention.html

func (*Handler) PutObjectTagging

func (h *Handler) PutObjectTagging(w http.ResponseWriter, r *http.Request)

PutObjectTagging handles PUT /{bucket}/{key}?tagging.

func (*Handler) PutPublicAccessBlock

func (h *Handler) PutPublicAccessBlock(w http.ResponseWriter, r *http.Request)

PutPublicAccessBlock handles PUT /{bucket}?publicAccessBlock AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutPublicAccessBlock.html

func (*Handler) RenameObject

func (h *Handler) RenameObject(w http.ResponseWriter, r *http.Request)

RenameObject handles PUT /{bucket}/{key}?rename AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_RenameObject.html

func (*Handler) RestoreObject

func (h *Handler) RestoreObject(w http.ResponseWriter, r *http.Request)

RestoreObject handles POST /{bucket}/{key}?restore AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_RestoreObject.html

func (*Handler) RootGet

func (h *Handler) RootGet(w http.ResponseWriter, r *http.Request)

RootGet dispatches GET / — either ListBuckets or ListDirectoryBuckets.

func (*Handler) SelectObjectContent

func (h *Handler) SelectObjectContent(w http.ResponseWriter, r *http.Request)

SelectObjectContent handles POST /{bucket}/{key}?select&select-type=2 AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_SelectObjectContent.html

func (*Handler) UpdateBucketMetadataTableConfiguration

func (h *Handler) UpdateBucketMetadataTableConfiguration(w http.ResponseWriter, r *http.Request)

UpdateBucketMetadataTableConfiguration handles PUT /{bucket}?metadataTable Covers UpdateBucketMetadataInventoryTableConfiguration and UpdateBucketMetadataJournalTableConfiguration. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UpdateBucketMetadataInventoryTableConfiguration.html

func (*Handler) UpdateObjectEncryption

func (h *Handler) UpdateObjectEncryption(w http.ResponseWriter, r *http.Request)

UpdateObjectEncryption handles PUT /{bucket}/{key}?encryption AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UpdateObjectEncryption.html

func (*Handler) UploadPart

func (h *Handler) UploadPart(w http.ResponseWriter, r *http.Request)

UploadPart handles PUT /{bucket}/{key}?partNumber=N&uploadId=xxx AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html

func (*Handler) UploadPartCopy

func (h *Handler) UploadPartCopy(w http.ResponseWriter, r *http.Request)

UploadPartCopy handles PUT /{bucket}/{key}?partNumber=N with x-amz-copy-source header. AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html

func (*Handler) WriteGetObjectResponse

func (h *Handler) WriteGetObjectResponse(w http.ResponseWriter, r *http.Request)

WriteGetObjectResponse handles POST /{bucket}/{key}?writeGetObjectResponse AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_WriteGetObjectResponse.html

type LambdaNotificationConfig

type LambdaNotificationConfig struct {
	ID     string              `json:"id"`
	ARN    string              `json:"arn"` // Lambda function ARN
	Events []string            `json:"events"`
	Filter *NotificationFilter `json:"filter,omitempty"`
}

LambdaNotificationConfig maps one set of S3 events to a Lambda function ARN.

type MultipartUpload

type MultipartUpload struct {
	UploadID    string            `json:"upload_id"`
	Bucket      string            `json:"bucket"`
	Key         string            `json:"key"`
	ContentType string            `json:"content_type"`
	Metadata    map[string]string `json:"metadata,omitempty"`
	Initiated   time.Time         `json:"initiated"`
}

MultipartUpload tracks an initiated multipart upload before completion.

type NotificationConfig

type NotificationConfig struct {
	QueueConfigurations  []QueueNotificationConfig  `json:"queue_configurations,omitempty"`
	LambdaConfigurations []LambdaNotificationConfig `json:"lambda_configurations,omitempty"`
	TopicConfigurations  []TopicNotificationConfig  `json:"topic_configurations,omitempty"`
}

NotificationConfig is the top-level structure stored per bucket. It mirrors the AWS S3 NotificationConfiguration XML schema.

type NotificationDispatcher

type NotificationDispatcher struct {
	// contains filtered or unexported fields
}

NotificationDispatcher reads per-bucket notification configs and routes matched events to destination sinks (SQS, SNS, Lambda).

func NewNotificationDispatcher

func NewNotificationDispatcher(
	store *s3Store,
	enqueuer events.MessageEnqueuer,
	invoker events.FunctionInvoker,
	bus *events.Bus,
	logger *zap.Logger,
	region string,
) (d *NotificationDispatcher, cancel func())

NewNotificationDispatcher creates a dispatcher and subscribes it to the given event bus for all S3 event types. The returned cancel function removes the subscriptions (useful in tests).

invoker may be nil when the lambda service is disabled; Lambda notification configs will be skipped in that case.

type NotificationFilter

type NotificationFilter struct {
	Key NotificationFilterKey `json:"key"`
}

NotificationFilter holds key-based filter rules.

type NotificationFilterKey

type NotificationFilterKey struct {
	Rules []NotificationFilterRule `json:"rules,omitempty"`
}

NotificationFilterKey is the S3Key element that contains filter rules.

type NotificationFilterRule

type NotificationFilterRule struct {
	Name  string `json:"name"` // "prefix" or "suffix"
	Value string `json:"value"`
}

NotificationFilterRule is a single prefix/suffix filter.

type Object

type Object struct {
	Bucket             string            `json:"bucket"`
	Key                string            `json:"key"`
	Body               []byte            `json:"-"`
	ContentType        string            `json:"content_type"`
	ContentLength      int64             `json:"content_length"`
	ETag               string            `json:"etag"`
	LastModified       time.Time         `json:"last_modified"`
	Metadata           map[string]string `json:"metadata,omitempty"`
	Tags               map[string]string `json:"tags,omitempty"`
	ContentDisposition string            `json:"content_disposition,omitempty"`
	ContentEncoding    string            `json:"content_encoding,omitempty"`
	ContentLanguage    string            `json:"content_language,omitempty"`
	CacheControl       string            `json:"cache_control,omitempty"`
	Expires            string            `json:"expires,omitempty"`
}

Object represents a stored S3 object. Body is stored on disk, not in the state store — the json:"-" tag excludes it from serialisation. Use s3Store.putObject/getObject to handle body persistence transparently.

type Part

type Part struct {
	PartNumber   int       `json:"part_number"`
	ETag         string    `json:"etag"`
	Size         int64     `json:"size"`
	LastModified time.Time `json:"last_modified"`
}

Part holds the metadata for one uploaded part. The body is stored on disk at partBodyPath(uploadID, partNumber).

type QueueNotificationConfig

type QueueNotificationConfig struct {
	ID     string              `json:"id"`
	ARN    string              `json:"arn"` // SQS queue ARN
	Events []string            `json:"events"`
	Filter *NotificationFilter `json:"filter,omitempty"`
}

QueueNotificationConfig maps one set of S3 events to an SQS queue ARN.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements router.Service for S3.

func New

func New(cfg *config.Config, store state.Store, logger *zap.Logger, clk clock.Clock, bus *events.Bus) *Service

New returns a configured S3 Service ready to be registered. bus is the shared event bus; pass events.NewBus() from the router.

func (*Service) GetObjectBytes

func (s *Service) GetObjectBytes(ctx context.Context, bucket, key string) ([]byte, error)

GetObjectBytes returns the full body of an S3 object for internal callers such as the Lambda S3-reactive sync watcher. Returns an error if the bucket or key does not exist.

func (*Service) InitNotifications

func (s *Service) InitNotifications(enqueuer events.MessageEnqueuer, invoker events.FunctionInvoker, bus *events.Bus, logger *zap.Logger)

InitNotifications wires up the S3 event notification dispatcher. Call this after constructing both the S3 and SQS services so the router can pass the SQS enqueuer without creating an import cycle between services. invoker may be nil when the lambda service is disabled.

func (*Service) Name

func (s *Service) Name() string

Name satisfies router.Service.

func (*Service) RegisterRoutes

func (s *Service) RegisterRoutes(r chi.Router)

RegisterRoutes mounts all S3 endpoints onto the given router. Route order matters in chi — more specific routes must come before wildcards. Every route delegates to a named dispatcher or handler; there are no inline protocol.NotImplementedXML calls here.

type TopicNotificationConfig

type TopicNotificationConfig struct {
	ID     string              `json:"id"`
	ARN    string              `json:"arn"` // SNS topic ARN
	Events []string            `json:"events"`
	Filter *NotificationFilter `json:"filter,omitempty"`
}

TopicNotificationConfig maps one set of S3 events to an SNS topic ARN.

type WebsiteConfiguration

type WebsiteConfiguration struct {
	IndexDocument string `json:"index_document,omitempty"`
	ErrorDocument string `json:"error_document,omitempty"`
}

WebsiteConfiguration stores S3 website configuration for a bucket.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL