s3

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package s3 implements bsw.BlockStorageWrapper for Amazon S3 and S3-compatible storages.

Index

Constants

View Source
const DefaultRetryCount = 5

DefaultRetryCount is used when Config.RetryCount is 0.

View Source
const MaxPresignTimeout = 7 * 24 * time.Hour

MaxPresignTimeout is the longest validity of a presigned URL allowed by S3.

Variables

View Source
var (
	ErrSessionInit = errors.Template("aws session init failed").
					Code("BSW-0201").StatusCode(500).Severity(errors.Critical)
	ErrCreateMultipartUpload = errors.Template("create multipart upload request failed").
								Code("BSW-0202").StatusCode(500).Severity(errors.Critical)
	ErrPresignPartURL = errors.Template("presigned part URL generation failed").
						Code("BSW-0203").StatusCode(500).Severity(errors.Critical)
	ErrCompleteMultipartUpload = errors.Template("multipart complete failed").
								Code("BSW-0204").StatusCode(500).Severity(errors.Critical)
	ErrPresignURL = errors.Template("presigned URL generation failed").
					Code("BSW-0205").StatusCode(500).Severity(errors.Critical)
)

Functions

This section is empty.

Types

type AwsCompletedPart deprecated

type AwsCompletedPart = bsw.Part

AwsCompletedPart describes an uploaded part.

Deprecated: use bsw.Part.

type Config

type Config struct {
	Region      *string `json:"region"`
	Credentials struct {
		AwsAccessKeyID     string `json:"awsAccessKeyId"`
		AwsSecretAccessKey string `json:"awsSecretAccessKey"`
	} `json:"credentials"`
	RetryCount int `json:"retryCount"`

	// Endpoint overrides the S3 endpoint, e.g. for MinIO. Optional.
	Endpoint string `json:"endpoint"`

	// ForcePathStyle uses path-style URLs (https://host/bucket/key)
	// instead of virtual-hosted ones. Usually needed with Endpoint.
	ForcePathStyle bool `json:"forcePathStyle"`
}

Config holds S3 settings.

type Service

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

Service implements bsw.BlockStorageWrapper for S3.

func New

func New(cfg *Config) *Service

New returns a service. cfg is copied. Init must be called before use.

func (*Service) CompleteMultipartUpload

func (s *Service) CompleteMultipartUpload(o *bsw.Object, uploadID string, parts []bsw.CompletedPart) error

CompleteMultipartUpload merges uploaded parts into a single object. Parts may be passed in any order, they are sent sorted by part number.

func (*Service) Init

func (s *Service) Init(ctx context.Context) error

Init creates an AWS session. It does not connect to S3.

func (*Service) Name added in v0.1.0

func (s *Service) Name() string

Name returns "s3".

func (*Service) PreSignGetObjectURL

func (s *Service) PreSignGetObjectURL(o *bsw.Object, timeout time.Duration) (string, error)

PreSignGetObjectURL returns presigned URL for GET object request.

func (*Service) PreSignMultipartObjectURL

func (s *Service) PreSignMultipartObjectURL(o *bsw.Object, timeout time.Duration) ([]string, string, error)

PreSignMultipartObjectURL starts a multipart upload and returns presigned PUT URLs for every part and the upload ID. If a part URL can not be generated, the upload is aborted.

func (*Service) PreSignPutObjectURL

func (s *Service) PreSignPutObjectURL(o *bsw.Object, timeout time.Duration) (string, error)

PreSignPutObjectURL returns presigned URL for PUT object request.

Jump to

Keyboard shortcuts

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