Help us shape the future of Go! Take the 2026 Go Developer Survey

s3

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package s3 provides a BinaryStore implementation backed by Amazon S3 or any S3-compatible object storage service (e.g. MinIO, Ceph, Cloudflare R2). Each named file maps 1:1 to an object inside the configured bucket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAWSS3

func NewAWSS3(log logger.Logger) binarystore.BinaryStore

NewAWSS3 returns a new AWSS3 binary store.

Types

type AWSS3

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

AWSS3 implements binarystore.BinaryStore using Amazon S3 or an S3-compatible object storage service.

func (*AWSS3) Close

func (s *AWSS3) Close() error

Close closes the underlying S3 client.

func (*AWSS3) Delete

func (s *AWSS3) Delete(ctx context.Context, req *binarystore.DeleteRequest) error

Delete removes an object from S3. If the object does not exist, binarystore.ErrFileNotFound is returned.

Because S3's DeleteObject is idempotent and succeeds for missing keys, an existence check is issued first, which requires the s3:GetObject permission and, for a missing key to be reported as 404 rather than 403, s3:ListBucket on the bucket. When either permission is absent S3 answers HeadObject for a missing key with 403 AccessDenied rather than 404 so that key existence is not leaked; in that case the delete proceeds without the existence guarantee rather than failing outright.

func (*AWSS3) Features

func (s *AWSS3) Features() []binarystore.Feature

Features returns the optional features supported by this component.

func (*AWSS3) Get

Get downloads binary data from S3 as a streaming reader.

The Data field of the returned GetResponse wraps the HTTP response body and must be closed by the caller when reading is complete.

func (*AWSS3) GetComponentMetadata

func (s *AWSS3) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap)

GetComponentMetadata returns the metadata schema for this component, used by the Dapr metadata linter.

func (*AWSS3) Init

func (s *AWSS3) Init(ctx context.Context, md binarystore.Metadata) error

Init initialises the S3 client from the component metadata.

func (*AWSS3) Set

func (s *AWSS3) Set(ctx context.Context, req *binarystore.SetRequest) error

Set uploads binary data to S3.

When req.Overwrite is false, an If-None-Match: * condition is applied so that the server rejects the upload atomically if the object already exists, returning binarystore.ErrFileAlreadyExists. This relies on the endpoint honouring conditional writes: AWS S3 and other conforming S3-compatible providers do, but a provider that does not recognize If-None-Match may silently ignore the header and perform a normal PutObject, overwriting any existing object without error. Only use req.Overwrite = false against endpoints that are known to support conditional writes.

When req.Overwrite is true, the object is created or replaced without a condition check.

Jump to

Keyboard shortcuts

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