gcs

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: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GCS

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

Google Cloud Storage client

func NewEngine

func NewEngine(projectID string, googleAccessID string, privateKey []byte) (*GCS, error)

NewEngine struct

func (*GCS) BucketExists

func (g *GCS) BucketExists(ctx context.Context, bucketName string) (found bool, err error)

BucketExists Checks if a bucket exists.

func (*GCS) Client

func (g *GCS) Client() interface{}

Client get disk client

func (*GCS) CopyFile

func (g *GCS) CopyFile(ctx context.Context, srcBucket, srcPath, destBucket, destPath string) error

CopyFile copy src to dest

func (*GCS) CreateBucket

func (g *GCS) CreateBucket(ctx context.Context, bucketName, region string) error

CreateBucket create bucket

func (*GCS) DeleteFile

func (g *GCS) DeleteFile(ctx context.Context, bucketName, fileName string) error

DeleteFile delete file

func (*GCS) DownloadFile

func (g *GCS) DownloadFile(
	ctx context.Context,
	bucketName, objectName, filePath string,
) error

DownloadFile downloads and saves the object as a file in the local filesystem.

func (*GCS) DownloadFileByProgress

func (g *GCS) DownloadFileByProgress(
	ctx context.Context,
	bucketName, objectName, filePath string,
	_ *pb.ProgressBar,
) error

DownloadFileByProgress downloads and saves the object as a file in the local filesystem.

func (*GCS) FileExist

func (g *GCS) FileExist(ctx context.Context, bucketName, fileName string) bool

FileExist check object exist. bucket + filename

func (*GCS) FilePath

func (g *GCS) FilePath(bucketName, fileName string) string

FilePath for store path + file name

func (*GCS) GetContent

func (g *GCS) GetContent(ctx context.Context, bucketName, fileName string) ([]byte, error)

GetContent for storage bucket + filename

func (*GCS) GetFileURL

func (g *GCS) GetFileURL(bucketName, fileName string) string

GetFileURL for storage host + bucket + filename

func (*GCS) SignedURL

func (g *GCS) SignedURL(ctx context.Context, bucketName, fileName string, opts *core.SignedURLOptions) (string, error)

SignedURL support signed URL

func (*GCS) UploadFile

func (g *GCS) UploadFile(ctx context.Context, bucketName, objectName string, content []byte, reader io.Reader) error

UploadFile to cloud storage

func (*GCS) UploadFileByReader

func (g *GCS) UploadFileByReader(
	ctx context.Context,
	bucketName, objectName string,
	reader io.Reader, contentType string,
	length int64,
) error

UploadFileByReader to cloud

Jump to

Keyboard shortcuts

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