cstorage

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWithoutStorageClient = errors.New(MsgErrWithoutStorageClient)
View Source
var MsgErrWithoutStorageClient = "error cstorage: select storage client"

Functions

This section is empty.

Types

type CStorage added in v1.0.1

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

func NewAwsS3Storage

func NewAwsS3Storage(cfg aws.Config) (*CStorage, error)

NewAwsS3Storage new instance of connection with AWS S3 storage, to close it just use Disconnect() or SimpleDisconnect()

func NewGoogleStorage

func NewGoogleStorage(ctx context.Context, opts ...option.ClientOption) (*CStorage, error)

NewGoogleStorage new instance of connection with Google storage, to close it just use Disconnect() or SimpleDisconnect()

func (*CStorage) CreateBucket added in v1.0.1

func (c *CStorage) CreateBucket(ctx context.Context, input CreateBucketInput) (err error)

CreateBucket creates the Bucket in the project.

func (*CStorage) DeleteBucket added in v1.0.1

func (c *CStorage) DeleteBucket(ctx context.Context, bucket string) error

DeleteBucket deletes the Bucket

func (*CStorage) DeleteBuckets added in v1.0.1

func (c *CStorage) DeleteBuckets(ctx context.Context, buckets ...string) []DeleteBucketsOutput

DeleteBuckets deletes multiple buckets mentioned in the input

func (*CStorage) DeleteObject added in v1.0.1

func (c *CStorage) DeleteObject(ctx context.Context, input DeleteObjectInput) (err error)

DeleteObject deletes the single specified object

func (*CStorage) DeleteObjects added in v1.0.1

func (c *CStorage) DeleteObjects(ctx context.Context, inputs ...DeleteObjectInput) []DeleteObjectsOutput

DeleteObjects deletes multiple objects specified in the input

func (*CStorage) DeleteObjectsByPrefix added in v1.0.1

func (c *CStorage) DeleteObjectsByPrefix(ctx context.Context, input DeletePrefixInput) error

DeleteObjectsByPrefix deletes all objects from a folder (prefix)

func (*CStorage) DeleteObjectsByPrefixes added in v1.0.1

func (c *CStorage) DeleteObjectsByPrefixes(ctx context.Context, inputs ...DeletePrefixInput) []DeletePrefixOutput

DeleteObjectsByPrefixes deletes all objects from all folders (prefix) mentioned in the input

func (*CStorage) Disconnect added in v1.0.1

func (c *CStorage) Disconnect() error

Disconnect close connect to google storage

func (*CStorage) GetObjectByKey added in v1.0.1

func (c *CStorage) GetObjectByKey(ctx context.Context, bucket, key string) (obj *Object, err error)

GetObjectByKey returns the data for the object by name

func (*CStorage) GetObjectUrl added in v1.0.3

func (c *CStorage) GetObjectUrl(bucket, key string) string

GetObjectUrl returns the object public url

func (*CStorage) ListObjects added in v1.0.1

func (c *CStorage) ListObjects(ctx context.Context, bucket string, opts ...*OptsListObjects) (
	sliceObjSummary []ObjectSummary, err error)

ListObjects return list objects by bucket, custom query using opts param (OptsListObjects)

func (*CStorage) PutObject added in v1.0.1

func (c *CStorage) PutObject(ctx context.Context, input PutObjectInput) (err error)

PutObject set the value passed in the indicated bucket

func (*CStorage) PutObjects added in v1.0.1

func (c *CStorage) PutObjects(ctx context.Context, inputs ...PutObjectInput) []PutObjectOutput

PutObjects set multiple values passed in the indicated bucket

func (*CStorage) SimpleDisconnect added in v1.0.1

func (c *CStorage) SimpleDisconnect()

SimpleDisconnect close connect to google storage, without error

type CreateBucketInput

type CreateBucketInput struct {
	// Bucket name of the bucket to be created (required)
	Bucket string
	// ProjectId project id where the bucket will be created (required only google storage)
	ProjectId string
	// Location bucket, if empty using default region
	Location string
}

CreateBucketInput input for creating a bucket

type DeleteBucketsOutput

type DeleteBucketsOutput struct {
	// Bucket deleted bucket name
	Bucket string
	// Err an error occurred while deleting the bucket
	Err error
}

DeleteBucketsOutput output of removing multiple buckets

type DeleteObjectInput

type DeleteObjectInput struct {
	// Bucket name of the bucket where the object will be deleted (required)
	Bucket string
	// Key of the object to be deleted (required)
	Key string
}

DeleteObjectInput input for removing an object from the bucket

type DeleteObjectsOutput

type DeleteObjectsOutput struct {
	// Bucket name of the bucket where the object was deleted
	Bucket string
	// Key of the object that was deleted
	Key string
	// Err error occurred when deleting the object
	Err error
}

DeleteObjectsOutput output of removing several objects from the bucket

type DeletePrefixInput

type DeletePrefixInput struct {
	// Bucket name of the bucket where the objects will be deleted (required)
	Bucket string
	// Prefix name where the objects will be deleted (required)
	Prefix string
}

DeletePrefixInput input to remove a folder (prefix) of objects from the bucket

type DeletePrefixOutput

type DeletePrefixOutput struct {
	// Bucket name of the bucket where the objects were deleted
	Bucket string
	// Prefix that was deleted
	Prefix string
	// Err an error occurred while deleting objects from the folder
	Err error
}

DeletePrefixOutput output of removing multiple object folders from bucket

type MimeType

type MimeType string
const (
	MimeTypePdf  MimeType = "application/pdf"
	MimeTypeText MimeType = "text/plain"
	MimeTypeAvif MimeType = "image/avif"
	MimeTypeCss  MimeType = "text/css; charset=utf-8"
	MimeTypeGif  MimeType = "image/gif"
	MimeTypeHtml MimeType = "text/html; charset=utf-8"
	MimeTypeJpeg MimeType = "image/jpeg"
	MimeTypeJs   MimeType = "text/javascript; charset=utf-8"
	MimeTypeJson MimeType = "application/json"
	MimeTypePng  MimeType = "image/png"
	MimeTypeSvg  MimeType = "image/svg+xml"
	MimeTypeWasm MimeType = "application/wasm"
	MimeTypeWebp MimeType = "image/webp"
	MimeTypeXml  MimeType = "text/xml; charset=utf-8"
)

func (MimeType) String

func (f MimeType) String() string

type Object

type Object struct {
	Key            string
	Url            string
	MimeType       MimeType
	Content        []byte
	Size           int64
	VersionId      string
	LastModifiedAt time.Time
}

func (Object) ParseContent

func (o Object) ParseContent(dest any) error

type ObjectPage

type ObjectPage struct {
}

type ObjectSummary

type ObjectSummary struct {
	Key            string
	Url            string
	Size           int64
	LastModifiedAt time.Time
}

type OptsListObjects

type OptsListObjects struct {
	// Delimiter returns results in a directory-like fashion.
	// Results will contain only objects whose names, aside from the
	// prefix, do not contain delimiter. Objects whose names,
	// aside from the prefix, contain delimiter will have their name,
	// truncated after the delimiter, returned in prefixes.
	// Duplicate prefixes are omitted.
	// Must be set to / when used with the MatchGlob parameter to filter results
	// in a directory-like mode.
	// Optional.
	Delimiter string
	// Prefix is the prefix filter to query objects
	// whose names begin with this prefix.
	// Optional.
	Prefix string
}

OptsListObjects bucket object search options

func MergeOptsListObjectsByParams added in v1.0.7

func MergeOptsListObjectsByParams(opts []*OptsListObjects) *OptsListObjects

MergeOptsListObjectsByParams assembles the OptsListObjects object from optional parameters.

func NewOptsListObjects

func NewOptsListObjects() *OptsListObjects

NewOptsListObjects creates a new OptsListObjects instance

func (*OptsListObjects) SetDelimiter

func (o *OptsListObjects) SetDelimiter(s string) *OptsListObjects

SetDelimiter sets value for the Delimiter field

func (*OptsListObjects) SetPrefix

func (o *OptsListObjects) SetPrefix(s string) *OptsListObjects

SetPrefix sets value for the Prefix field

type PutObjectInput

type PutObjectInput struct {
	// Bucket name of the bucket where the object will be created (required)
	Bucket string
	// Key of the object that will be created (required)
	Key string
	// MimeType type of content of the object that will be created (required)
	MimeType MimeType
	// Content of the object that will be created (required)
	Content any
}

PutObjectInput input for creating/updating an object in the bucket

type PutObjectOutput

type PutObjectOutput struct {
	// Bucket name of the bucket where the object will be created
	Bucket string
	// Key of the object that will be created
	Key string
	// Err error occurred when putting the object
	Err error
}

PutObjectOutput output for creating/updating multiple objects in the bucket

Jump to

Keyboard shortcuts

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