s3

package
v0.0.0-...-b155b17 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package s3 implements s3 client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*s3.Client
	// contains filtered or unexported fields
}

Client aws s3 client

func NewClient

func NewClient(ctx context.Context, endpoint, key, secret string, opts ...ClientOption) (*Client, error)

NewClient new s3 client

if set kms engine by WithKMS, ListObject/GetObject will enable transparent encryption.

func (*Client) Bucket

func (c *Client) Bucket() string

Bucket return bucket name

func (*Client) DeleteObject

func (c *Client) DeleteObject(ctx context.Context,
	params *s3.DeleteObjectInput,
	optFns ...func(*s3.Options)) (*s3.DeleteObjectOutput, error)

DeleteObject delete s3 object

func (*Client) ErrNotFound

func (c *Client) ErrNotFound(err error) bool

ErrNotFound check error is not found

func (*Client) GetObject

func (c *Client) GetObject(ctx context.Context,
	params *s3.GetObjectInput,
	optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)

GetObject get s3 object

func (*Client) GetObjectEncrypt

func (c *Client) GetObjectEncrypt(ctx context.Context,
	kms KMS,
	params *s3.GetObjectInput,
	optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)

GetObjectEncrypt get s3 object

func (*Client) IsObjectExist

func (c *Client) IsObjectExist(ctx context.Context, key string) (bool, error)

IsObjectExist check object exist

func (*Client) ListObjectsV2

func (c *Client) ListObjectsV2(ctx context.Context,
	params *s3.ListObjectsV2Input,
	optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)

ListObjectsV2 list object

func (*Client) PutObject

func (c *Client) PutObject(ctx context.Context,
	params *s3.PutObjectInput,
	optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)

PutObject put s3 object

func (*Client) PutObjectEncrypt

func (c *Client) PutObjectEncrypt(ctx context.Context,
	kms KMS,
	params *s3.PutObjectInput,
	optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)

PutObjectEncrypt put s3 object

func (*Client) Region

func (c *Client) Region() string

Region return region name

type ClientOption

type ClientOption func(*clientOption) error

ClientOption optional arguments for client

func WithBucket

func WithBucket(bucket string) ClientOption

WithBucket set default bucket

func WithDebugLog

func WithDebugLog() ClientOption

WithDebugLog enable debug log

func WithRegion

func WithRegion(region string) ClientOption

WithRegion set default region

type KMS

type KMS interface {
	// AddKek add new kek
	AddKek(ctx context.Context, kekID uint16, kek []byte) error
	// Kek get current used kek
	// Kek(ctx context.Context) (kekID uint16, kek []byte, err error)
	// Keks export all keks
	// Keks(ctx context.Context) (keks map[uint16][]byte, err error)
	// DeriveKeyByID derive key by specific kek id  and dek id
	// DeriveKeyByID(ctx context.Context,
	// 	kekID uint16,
	// 	dekID []byte,
	// 	length int) (dek []byte, err error)
	// // DeriveKey derive random key by current kek
	// DeriveKey(ctx context.Context, length int) (kekID uint16, dekID, dek []byte, err error)
	// Encrypt encrypt data
	Encrypt(ctx context.Context, plaintext,
		additionalData []byte) (ed *gkms.EncryptedData, err error)
	// Decrypt decrypt data
	Decrypt(ctx context.Context,
		ed *gkms.EncryptedData, additionalData []byte) (plaintext []byte, err error)
}

KMS KMS engine

Jump to

Keyboard shortcuts

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