core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SignedURLOptions

type SignedURLOptions struct {
	Expiry          time.Duration
	DefaultFilename string
}

SignedURLOptions download options

type Storage

type Storage interface {
	// CreateBucket for create new folder
	CreateBucket(ctx context.Context, bucketName string, region string) error
	// BucketExists Checks if a bucket exists.
	BucketExists(ctx context.Context, bucketName string) (found bool, err error)
	// UploadFile for upload single file
	UploadFile(ctx context.Context, bucketName string, objectName string, content []byte, reader io.Reader) error
	// UploadFileByReader for upload single file
	UploadFileByReader(
		ctx context.Context,
		bucketName string,
		objectName string,
		reader io.Reader,
		contentType string,
		length int64,
	) error
	// DeleteFile for delete single file
	DeleteFile(ctx context.Context, bucketName string, fileName string) error
	// FilePath for store path + file name
	FilePath(bucketName string, fileName string) string
	// GetFile for storage host + bucket + filename
	GetFileURL(bucketName string, fileName string) string
	// DownloadFile downloads and saves the object as a file in the local filesystem.
	DownloadFile(ctx context.Context, bucketName string, objectName string, filePath string) error
	// DownloadFileByProgress downloads and saves the object as a file in the local filesystem.
	DownloadFileByProgress(
		ctx context.Context,
		bucketName string,
		objectName string,
		filePath string,
		bar *pb.ProgressBar,
	) error
	// FileExist check object exist. bucket + filename
	FileExist(ctx context.Context, bucketName string, fileName string) bool
	// GetContent for storage bucket + filename
	GetContent(ctx context.Context, bucketName string, fileName string) ([]byte, error)
	// Copy Create or replace an object through server-side copying of an existing object.
	CopyFile(ctx context.Context, srcBucket string, srcPath string, dstBucket string, dstPath string) error
	// Client get storage client
	Client() interface{}
	// SignedURL get signed URL
	SignedURL(ctx context.Context, bucketName string, filePath string, opts *SignedURLOptions) (string, error)
}

Storage for s3 and disk

Jump to

Keyboard shortcuts

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