cloudstore

package
v0.0.0-...-16b3867 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ObjectCreateError = errs.NotCreatedError.NewSubtype("Object Write Error")
View Source
var ObjectWriteError = errs.NotWrittenError.NewSubtype("Object Write Error")

Functions

func BucketExists

func BucketExists(ctx context.Context, bh *gcs.BucketHandle) bool

BucketExists returns true if the bucket exists, false otherwise.

func Client

func Client(ctx context.Context, options ...option.ClientOption) (*gcs.Client, error)

Client creates a new GCS client with the given options.

func CloudStorageEvent

func CloudStorageEvent(c *gin.Context)

func CreateBucket

func CreateBucket(ctx context.Context, bucket string) (*gcs.BucketHandle, error)

CreateBucket creates a new bucket with the given name.

func DeleteBucket

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

DeleteBucket deletes the bucket with the given name.

func DeleteObject

func DeleteObject(ctx context.Context, bh *gcs.BucketHandle, path string) error

DeleteObject deletes the object at the given path in the given bucket.

func ListAllBuckets

func ListAllBuckets(ctx context.Context) []string

ListAllBuckets returns a list of all buckets in the project.

Types

type Bucket

type Bucket struct {
	Name    string     `json:"name"`
	Objects []Metadata `json:"objects"`
}

func BucketWithObjects

func BucketWithObjects(bucket string) (*Bucket, error)

BucketWithObjects returns a Bucket object with all objects in the bucket.

type Location

type Location struct {
	Bucket string `json:"bucket"`
	Name   string `json:"name"`
}

func (Location) String

func (l Location) String() string

type Metadata

type Metadata struct {
	Path          string               `json:"path"`
	Size          int64                `json:"size"`
	ContentType   string               `json:"content_type"`
	CreatedAt     *timestamp.Timestamp `json:"created_at"`
	LastUpdatedAt *timestamp.Timestamp `json:"last_updated_at"`
}

func AttrToObject

func AttrToObject(attrs *gcs.ObjectAttrs) Metadata

AttrToObject converts a GCS object attributes to a Metadata object.

func (Metadata) Dir

func (o Metadata) Dir() string

func (Metadata) Name

func (o Metadata) Name() string

type ReadResult

type ReadResult struct {
	BytesRead int64 `json:"bytes_read"`
	Error     error `json:"error"`
}

func ReadObject

func ReadObject(ctx context.Context, bucket string, path string, dst io.Writer) ReadResult

type WriteResult

type WriteResult struct {
	BytesWritten int64 `json:"bytes_written"`
	Error        error `json:"error"`
}

func WriteObject

func WriteObject(ctx context.Context, bucket string, path string, src io.Reader) WriteResult

WriteObject writes the given io.Reader to the object at the given path in the given bucket.

Jump to

Keyboard shortcuts

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