sos

package
v1.68.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 29 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"
)
View Source
const (
	BucketPrefix    = "sos://"
	TimestampFormat = "2006-01-02 15:04:05 MST"
)
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
)

Functions

func BucketCannedACLToStrings

func BucketCannedACLToStrings() []string

func ObjectCannedACLToStrings

func ObjectCannedACLToStrings() []string

func ObjectHeadersFromS3

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

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 BucketObjectOwnership

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

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 {
	// contains filtered or unexported fields
}

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) 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) 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) DeleteObjects

func (c *Client) DeleteObjects(ctx context.Context, bucket, prefix string, recursive bool) ([]s3types.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 string, object *s3types.Object, dst string) error

func (*Client) DownloadFiles

func (c *Client) DownloadFiles(ctx context.Context, config *DownloadConfig) 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) GetBucketObjectOwnership

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

func (*Client) ListObjects

func (c *Client) ListObjects(ctx context.Context, bucket, prefix string, recursive, stream bool) (output.Outputter, 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) (output.Outputter, 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 DownloadConfig

type DownloadConfig struct {
	Bucket      string
	Prefix      string
	Source      string
	Destination string
	Objects     []*s3types.Object
	Recursive   bool
	Overwrite   bool
	DryRun      bool
}

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 ListObjectsItemOutput

type ListObjectsItemOutput struct {
	Path         string `json:"name"`
	Size         int64  `json:"size"`
	LastModified string `json:"last_modified,omitempty"`
	Dir          bool   `json:"dir"`
}

type ListObjectsOutput

type ListObjectsOutput []ListObjectsItemOutput

func (*ListObjectsOutput) ToJSON

func (o *ListObjectsOutput) ToJSON()

func (*ListObjectsOutput) ToTable

func (o *ListObjectsOutput) ToTable()

func (*ListObjectsOutput) ToText

func (o *ListObjectsOutput) ToText()

type ShowBucketOutput

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

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"`
}

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
}

Jump to

Keyboard shortcuts

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