sos

package
v1.96.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACLGranteeAllUsers           = "http://acs.amazonaws.com/groups/global/AllUsers"
	ACLGranteeAuthenticatedUsers = "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"

	SetACLCmdFlagRead        = "read"
	SetACLCmdFlagWrite       = "write"
	SetACLCmdFlagReadACP     = "read-acp"
	SetACLCmdFlagWriteACP    = "write-acp"
	SetACLCmdFlagFullControl = "full-control"
)
View Source
const (
	ObjectHeaderCacheControl        = "Cache-Control"
	ObjectHeaderContentDisposition  = "Content-Disposition"
	ObjectHeaderContentEncoding     = "Content-Encoding"
	ObjectHeaderContentLanguage     = "Content-Language"
	ObjectHeaderContentType         = "Content-Type"
	ObjectHeaderExpires             = "Expires"
	ObjectHeaderLifecycleExpiration = "Expires-At"
)
View Source
const (
	BucketPrefix = "sos://"
)
View Source
const MetadataForbiddenCharset = `()<>@,;!:\\'&"/[]?_={} `

Variables

View Source
var (
	// CommonConfigOptFns represents the list of AWS SDK configuration options common
	// to all commands. In addition to those, some commands can/must set additional options
	// specific to their execution context.
	CommonConfigOptFns           []func(*awsconfig.LoadOptions) error
	ClientNewUploaderDefaultFunc = s3manager.NewUploader
)

Functions

func BucketCannedACLToStrings

func BucketCannedACLToStrings() []string

func GetCommonPrefixDeduplicator added in v1.71.0

func GetCommonPrefixDeduplicator(stream bool) func([]types.CommonPrefix) []string

func IsTraversalPath added in v1.94.1

func IsTraversalPath(key string) bool

func ObjectCannedACLToStrings

func ObjectCannedACLToStrings() []string

func ObjectHeadersFromS3

func ObjectHeadersFromS3(o *s3.GetObjectOutput) (map[string]string, error)

ObjectHeadersFromS3 returns mutable object headers in a human-friendly key/value form.

Types

type ACL

type ACL struct {
	Canned      string `json:"-"`
	Read        string `json:"read"`
	Write       string `json:"write"`
	ReadACP     string `json:"read_acp"`
	WriteACP    string `json:"write_acp"`
	FullControl string `json:"full_control"`
}

func ACLFromS3

func ACLFromS3(grants []s3types.Grant) ACL

ACLFromS3 converts an S3 ACL Grant to the local ACL representation.

type BucketLifecycle added in v1.95.5

type BucketLifecycle struct {
	BucketLifecycleConf
	Bucket string
}

func (*BucketLifecycle) ToJSON added in v1.95.5

func (o *BucketLifecycle) ToJSON()

func (*BucketLifecycle) ToTable added in v1.95.5

func (o *BucketLifecycle) ToTable()

func (*BucketLifecycle) ToText added in v1.95.5

func (o *BucketLifecycle) ToText()

type BucketLifecycleAndOperator added in v1.95.5

type BucketLifecycleAndOperator struct {
	Prefix                *string
	ObjectSizeGreaterThan *int64
	ObjectSizeLessThan    *int64
}

type BucketLifecycleConf added in v1.95.5

type BucketLifecycleConf struct {
	Rules []BucketLifecycleRule
}

func (*BucketLifecycleConf) FromS3 added in v1.95.5

func (*BucketLifecycleConf) ToS3 added in v1.95.5

type BucketLifecycleConfRuleFilter added in v1.95.5

type BucketLifecycleConfRuleFilter struct {
	Prefix                *string
	And                   *BucketLifecycleAndOperator
	ObjectSizeGreaterThan *int64
	ObjectSizeLessThan    *int64
}

Decoding json into the default types.LifecycleRuleFilter fails so we partially recreate the original struct with conversion methods

type BucketLifecycleRule added in v1.95.5

type BucketLifecycleRule struct {
	Status types.ExpirationStatus

	AbortIncompleteMultipartUpload *types.AbortIncompleteMultipartUpload

	Expiration *types.LifecycleExpiration

	Filter *BucketLifecycleConfRuleFilter

	ID *string

	NoncurrentVersionExpiration *types.NoncurrentVersionExpiration
}

type BucketObjectOwnership

type BucketObjectOwnership string
const (
	ObjectOwnershipObjectWriter         BucketObjectOwnership = BucketObjectOwnership(types.ObjectOwnershipObjectWriter)
	ObjectOwnershipBucketOwnerPreferred BucketObjectOwnership = BucketObjectOwnership(types.ObjectOwnershipBucketOwnerPreferred)
	ObjectOwnershipBucketOwnerEnforced  BucketObjectOwnership = "BucketOwnerEnforced"
)

type BucketReplicationConf added in v1.84.0

type BucketReplicationConf struct {
	Role  *string
	Rules []BucketReplicationRule
}

func (*BucketReplicationConf) FromS3 added in v1.84.0

func (*BucketReplicationConf) ToS3 added in v1.84.0

type BucketReplicationConfRuleFilter added in v1.84.0

type BucketReplicationConfRuleFilter struct {
	Prefix string
}

Decoding json into the default types.ReplicationRuleFilter fails so we partially recreate the original struct with conversion methods

type BucketReplicationRule added in v1.84.0

type BucketReplicationRule struct {
	Destination *types.Destination

	Status types.ReplicationRuleStatus

	DeleteMarkerReplication *types.DeleteMarkerReplication

	ExistingObjectReplication *types.ExistingObjectReplication

	Filter BucketReplicationConfRuleFilter

	ID *string

	Priority int32
}

type CORSRule

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

func CORSRulesFromS3

func CORSRulesFromS3(v *s3.GetBucketCorsOutput) []CORSRule

CORSRulesFromS3 converts a list of S3 CORS rules to a list of CORSRule.

type Client

type Client struct {
	S3Client        S3API
	Zone            string
	NewUploaderFunc func(client s3manager.UploadAPIClient, options ...func(*s3manager.Uploader)) Uploader
}

func NewStorageClient

func NewStorageClient(ctx context.Context, opts ...ClientOpt) (*Client, error)

func (*Client) AddBucketCORSRule

func (c *Client) AddBucketCORSRule(ctx context.Context, bucket string, cors *CORSRule) error

func (*Client) AddObjectMetadata

func (c *Client) AddObjectMetadata(ctx context.Context, bucket, key string, metadata map[string]string) error

func (*Client) AddObjectsMetadata

func (c *Client) AddObjectsMetadata(ctx context.Context, bucket, prefix string, metadata map[string]string, recursive bool) error

func (*Client) BucketVersioningStatus added in v1.70.0

func (c *Client) BucketVersioningStatus(ctx context.Context, bucket string) (output.Outputter, error)

func (*Client) CopyObject

func (c *Client) CopyObject(ctx context.Context, bucket, key string) (*s3.CopyObjectInput, error)

copyObject is a helper function to be used in commands involving object copying such as metadata/headers manipulation, retrieving information about the targeted object for a later copy.

func (*Client) CreateNewBucket

func (c *Client) CreateNewBucket(ctx context.Context, name, acl string) error

func (Client) DeleteBucket

func (c Client) DeleteBucket(ctx context.Context, bucket string, recursive bool) error

func (*Client) DeleteBucketCORS

func (c *Client) DeleteBucketCORS(ctx context.Context, bucket string) error

func (*Client) DeleteBucketLifecycle added in v1.95.5

func (c *Client) DeleteBucketLifecycle(ctx context.Context, bucket string) error

func (*Client) DeleteBucketReplication added in v1.84.0

func (c *Client) DeleteBucketReplication(ctx context.Context, bucket string) error

func (*Client) DeleteObject added in v1.95.2

func (c *Client) DeleteObject(ctx context.Context, bucket, key string) error

func (*Client) DeleteObjectHeaders

func (c *Client) DeleteObjectHeaders(ctx context.Context, bucket, key string, headers []string) error

func (*Client) DeleteObjectMetadata

func (c *Client) DeleteObjectMetadata(ctx context.Context, bucket, key string, mdKeys []string) error

func (*Client) DeleteObjectVersions added in v1.86.0

func (c *Client) DeleteObjectVersions(ctx context.Context, bucket, prefix string) (<-chan types.DeletedObject, <-chan error)

func (*Client) DeleteObjects

func (c *Client) DeleteObjects(ctx context.Context, bucket, prefix string, recursive bool) ([]types.DeletedObject, error)

func (*Client) DeleteObjectsHeaders

func (c *Client) DeleteObjectsHeaders(ctx context.Context, bucket, prefix string, headers []string, recursive bool) error

func (*Client) DeleteObjectsMetadata

func (c *Client) DeleteObjectsMetadata(ctx context.Context, bucket, prefix string, mdKeys []string, recursive bool) error

func (*Client) DownloadFile

func (c *Client) DownloadFile(
	ctx context.Context,
	bucket, dst string,
	object *types.Object,
	overwrite, dryRun bool,
) error

func (*Client) DownloadFiles

func (c *Client) DownloadFiles(
	ctx context.Context,
	bucket, prefix, src, dst string,
	objects []*types.Object,
	overwrite, dryRun bool,
) error

func (*Client) EnableBucketVersioning added in v1.70.0

func (c *Client) EnableBucketVersioning(ctx context.Context, bucket string) error

func (*Client) EstimatePartSize

func (c *Client) EstimatePartSize(f *os.File) (int64, error)

func (*Client) ForEachObject

func (c *Client) ForEachObject(ctx context.Context, bucket, prefix string, recursive bool, fn func(*s3types.Object) error) error

forEachObject is a convenience wrapper to execute a callback function on each object listed in the specified bucket/prefix. Upon callback function error, the whole processing ends.

func (*Client) GenPresignedURL

func (c *Client) GenPresignedURL(ctx context.Context, method, bucket, key string, expires time.Duration) (string, error)

func (*Client) GetBucketLifecycle added in v1.95.5

func (c *Client) GetBucketLifecycle(ctx context.Context, bucket string) (*BucketLifecycle, error)

func (Client) GetBucketObjectOwnership

func (c Client) GetBucketObjectOwnership(ctx context.Context, bucket string) (BucketObjectOwnership, error)

func (Client) GetBucketObjectOwnershipInfo added in v1.70.0

func (c Client) GetBucketObjectOwnershipInfo(ctx context.Context, bucket string) (output.Outputter, error)

func (*Client) GetBucketReplication added in v1.84.0

func (c *Client) GetBucketReplication(ctx context.Context, bucket string) (*bucketReplication, error)

func (*Client) GetBucketVersioning added in v1.70.0

func (c *Client) GetBucketVersioning(ctx context.Context, bucket string) (types.BucketVersioningStatus, error)

func (*Client) ListObjects

func (c *Client) ListObjects(ctx context.Context, list listFunc[object.ObjectInterface], recursive, stream bool, filters []object.ObjectFilterFunc) (*object.ListObjectsOutput, error)

func (*Client) ListObjectsFunc added in v1.71.0

func (c *Client) ListObjectsFunc(bucket, prefix string, recursive, stream bool) listFunc[object.ObjectInterface]

func (*Client) ListObjectsVersions added in v1.71.0

func (c *Client) ListObjectsVersions(ctx context.Context, list listFunc[object.ObjectVersionInterface], recursive, stream bool,
	filters []object.ObjectFilterFunc,
	versionFilters []object.ObjectVersionFilterFunc) (*object.ListObjectsOutput, error)

func (*Client) ListVersionedObjectsFunc added in v1.71.0

func (c *Client) ListVersionedObjectsFunc(bucket, prefix string, recursive, stream bool) listFunc[object.ObjectVersionInterface]

func (*Client) MoveObject added in v1.95.2

func (c *Client) MoveObject(ctx context.Context, srcBucket, srcKey, dstBucket, dstKey string, multipartConcurrency int, verbose bool) error

func (*Client) NewUploader added in v1.70.0

func (c *Client) NewUploader(client s3manager.UploadAPIClient, options ...func(*s3manager.Uploader)) Uploader

func (*Client) PutBucketLifecycle added in v1.95.5

func (c *Client) PutBucketLifecycle(ctx context.Context, bucket string, conf *types.BucketLifecycleConfiguration) error

func (*Client) PutBucketReplication added in v1.84.0

func (c *Client) PutBucketReplication(ctx context.Context, bucket string, conf *types.ReplicationConfiguration) error

func (*Client) SetBucketACL

func (c *Client) SetBucketACL(ctx context.Context, bucket string, acl *ACL) error

func (Client) SetBucketObjectOwnership

func (c Client) SetBucketObjectOwnership(ctx context.Context, bucket string, ownership BucketObjectOwnership) error

func (*Client) SetObjectACL

func (c *Client) SetObjectACL(ctx context.Context, bucket, key string, acl *ACL) error

func (*Client) SetObjectsACL

func (c *Client) SetObjectsACL(ctx context.Context, bucket, prefix string, acl *ACL, recursive bool) error

func (*Client) ShowBucket

func (c *Client) ShowBucket(ctx context.Context, bucket string) (output.Outputter, error)

func (*Client) ShowObject

func (c *Client) ShowObject(ctx context.Context, bucket, key string) (*ShowObjectOutput, error)

func (*Client) SuspendBucketVersioning added in v1.70.0

func (c *Client) SuspendBucketVersioning(ctx context.Context, bucket string) error

func (*Client) UpdateObjectHeaders

func (c *Client) UpdateObjectHeaders(ctx context.Context, bucket, key string, headers map[string]*string) error

func (*Client) UpdateObjectsHeaders

func (c *Client) UpdateObjectsHeaders(ctx context.Context, bucket, prefix string, headers map[string]*string, recursive bool) error

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, bucket, file, key, acl string) error

func (*Client) UploadFiles

func (c *Client) UploadFiles(ctx context.Context, sources []string, config *StorageUploadConfig) error

type ClientOpt

type ClientOpt func(*Client) error

func ClientOptWithZone

func ClientOptWithZone(zone string) ClientOpt

func ClientOptZoneFromBucket

func ClientOptZoneFromBucket(ctx context.Context, bucket string) ClientOpt

type ListBucketsItemOutput

type ListBucketsItemOutput struct {
	Name    string `json:"name"`
	Zone    string `json:"zone"`
	Size    int64  `json:"size"`
	Created string `json:"created"`
}

type ListBucketsOutput

type ListBucketsOutput []ListBucketsItemOutput

func (*ListBucketsOutput) ToJSON

func (o *ListBucketsOutput) ToJSON()

func (*ListBucketsOutput) ToTable

func (o *ListBucketsOutput) ToTable()

func (*ListBucketsOutput) ToText

func (o *ListBucketsOutput) ToText()

type ObjectListing added in v1.71.0

type ObjectListing[ObjectType object.ObjectInterface] struct {
	List           []ObjectType
	CommonPrefixes []string
}

type S3API added in v1.70.0

type S3API interface {
	s3manager.UploadAPIClient

	DeleteObjects(ctx context.Context, params *s3.DeleteObjectsInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectsOutput, error)
	DeleteObject(ctx context.Context, params *s3.DeleteObjectInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectOutput, error)
	GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
	GetObjectAcl(ctx context.Context, params *s3.GetObjectAclInput, optFns ...func(*s3.Options)) (*s3.GetObjectAclOutput, error)
	ListObjectsV2(ctx context.Context, params *s3.ListObjectsV2Input, optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
	ListObjectVersions(ctx context.Context, params *s3.ListObjectVersionsInput, optFns ...func(*s3.Options)) (*s3.ListObjectVersionsOutput, error)
	CopyObject(ctx context.Context, params *s3.CopyObjectInput, optFns ...func(*s3.Options)) (*s3.CopyObjectOutput, error)
	DeleteBucketCors(ctx context.Context, params *s3.DeleteBucketCorsInput, optFns ...func(*s3.Options)) (*s3.DeleteBucketCorsOutput, error)
	GetBucketCors(ctx context.Context, params *s3.GetBucketCorsInput, optFns ...func(*s3.Options)) (*s3.GetBucketCorsOutput, error)
	PutBucketCors(ctx context.Context, params *s3.PutBucketCorsInput, optFns ...func(*s3.Options)) (*s3.PutBucketCorsOutput, error)
	PutBucketAcl(ctx context.Context, params *s3.PutBucketAclInput, optFns ...func(*s3.Options)) (*s3.PutBucketAclOutput, error)
	PutObjectAcl(ctx context.Context, params *s3.PutObjectAclInput, optFns ...func(*s3.Options)) (*s3.PutObjectAclOutput, error)
	CreateBucket(ctx context.Context, params *s3.CreateBucketInput, optFns ...func(*s3.Options)) (*s3.CreateBucketOutput, error)
	GetBucketAcl(ctx context.Context, params *s3.GetBucketAclInput, optFns ...func(*s3.Options)) (*s3.GetBucketAclOutput, error)
	GetBucketOwnershipControls(ctx context.Context, params *s3.GetBucketOwnershipControlsInput, optFns ...func(*s3.Options)) (*s3.GetBucketOwnershipControlsOutput, error)
	PutBucketOwnershipControls(ctx context.Context, params *s3.PutBucketOwnershipControlsInput, optFns ...func(*s3.Options)) (*s3.PutBucketOwnershipControlsOutput, error)
	GetBucketVersioning(ctx context.Context, params *s3.GetBucketVersioningInput, optFns ...func(*s3.Options)) (*s3.GetBucketVersioningOutput, error)
	PutBucketVersioning(ctx context.Context, params *s3.PutBucketVersioningInput, optFns ...func(*s3.Options)) (*s3.PutBucketVersioningOutput, error)
	ListMultipartUploads(ctx context.Context, params *s3.ListMultipartUploadsInput, optFns ...func(*s3.Options)) (*s3.ListMultipartUploadsOutput, error)
	AbortMultipartUpload(ctx context.Context, params *s3.AbortMultipartUploadInput, optFns ...func(*s3.Options)) (*s3.AbortMultipartUploadOutput, error)
	DeleteBucket(ctx context.Context, params *s3.DeleteBucketInput, optFns ...func(*s3.Options)) (*s3.DeleteBucketOutput, error)
	GetBucketReplication(ctx context.Context, params *s3.GetBucketReplicationInput, optFns ...func(*s3.Options)) (*s3.GetBucketReplicationOutput, error)
	PutBucketReplication(ctx context.Context, params *s3.PutBucketReplicationInput, optFns ...func(*s3.Options)) (*s3.PutBucketReplicationOutput, error)
	DeleteBucketReplication(ctx context.Context, params *s3.DeleteBucketReplicationInput, optFns ...func(*s3.Options)) (*s3.DeleteBucketReplicationOutput, error)
	GetBucketLifecycleConfiguration(ctx context.Context, params *s3.GetBucketLifecycleConfigurationInput, optFns ...func(*s3.Options)) (*s3.GetBucketLifecycleConfigurationOutput, error)
	PutBucketLifecycleConfiguration(ctx context.Context, params *s3.PutBucketLifecycleConfigurationInput, optFns ...func(*s3.Options)) (*s3.PutBucketLifecycleConfigurationOutput, error)
	DeleteBucketLifecycle(ctx context.Context, params *s3.DeleteBucketLifecycleInput, optFns ...func(*s3.Options)) (*s3.DeleteBucketLifecycleOutput, error)
	HeadObject(ctx context.Context, params *s3.HeadObjectInput, optFns ...func(*s3.Options)) (*s3.HeadObjectOutput, error)
	UploadPartCopy(ctx context.Context, params *s3.UploadPartCopyInput, optFns ...func(*s3.Options)) (*s3.UploadPartCopyOutput, error)
}

type ShowBucketOutput

type ShowBucketOutput struct {
	Name            string                `json:"name"`
	Zone            string                `json:"zone"`
	ACL             ACL                   `json:"acl"`
	CORS            []CORSRule            `json:"cors"`
	ObjectOwnership BucketObjectOwnership `json:"objectOwnership"`
}

func (*ShowBucketOutput) ToJSON

func (o *ShowBucketOutput) ToJSON()

func (*ShowBucketOutput) ToTable

func (o *ShowBucketOutput) ToTable()

func (*ShowBucketOutput) ToText

func (o *ShowBucketOutput) ToText()

type ShowObjectOutput

type ShowObjectOutput struct {
	Path              string            `json:"name"`
	Bucket            string            `json:"bucket"`
	LastModified      string            `json:"last_modified"`
	Size              int64             `json:"size"`
	ACL               ACL               `json:"acl"`
	Metadata          map[string]string `json:"metadata"`
	Headers           map[string]string `json:"headers"`
	URL               string            `json:"url"`
	ReplicationStatus string            `json:"replication_status"`
}

func (*ShowObjectOutput) ToJSON

func (o *ShowObjectOutput) ToJSON()

func (*ShowObjectOutput) ToTable

func (o *ShowObjectOutput) ToTable()

func (*ShowObjectOutput) ToText

func (o *ShowObjectOutput) ToText()

type StorageUploadConfig

type StorageUploadConfig struct {
	Bucket    string
	Prefix    string
	ACL       string
	Recursive bool
	DryRun    bool
}

type Uploader added in v1.70.0

type Uploader interface {
	Upload(ctx context.Context, input *s3.PutObjectInput, opts ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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