gcs

package
v0.0.0-...-4b25d55 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 9 Imported by: 30

Documentation

Overview

Package gcs provides wrappers around Google Cloud Storage (GCS) APIs. Package uses Application Default Credentials assuming that the program runs on GCE.

See the following links for details and API reference: https://cloud.google.com/go/getting-started/using-cloud-storage https://godoc.org/cloud.google.com/go/storage

Index

Constants

View Source
const (
	PublicPrefix        = "https://storage.googleapis.com/"
	AuthenticatedPrefix = "https://storage.cloud.google.com/"
)

Where things get published.

Variables

View Source
var ErrFileNotFound = errors.New("the requested files does not exist")

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(ctx context.Context) (*Client, error)

func (*Client) Close

func (client *Client) Close()

func (*Client) DeleteFile

func (client *Client) DeleteFile(gcsFile string) error

func (*Client) FileExists

func (client *Client) FileExists(gcsFile string) (bool, error)

func (*Client) FileWriter

func (client *Client) FileWriter(gcsFile string) (io.WriteCloser, error)

func (*Client) FileWriterExt

func (client *Client) FileWriterExt(gcsFile, contentType, contentEncoding string) (io.WriteCloser, error)

func (*Client) GetDownloadURL

func (client *Client) GetDownloadURL(gcsFile string, publicURL bool) string

func (*Client) ListObjects

func (client *Client) ListObjects(bucketObjectPath string) ([]*Object, error)

ListObjects expects "bucket/path" or "bucket" as input.

func (*Client) Publish

func (client *Client) Publish(gcsFile string) error

Publish lets any user read gcsFile.

func (*Client) Read

func (client *Client) Read(gcsFile string) (*File, error)

func (*Client) UploadFile

func (client *Client) UploadFile(localFile, gcsFile, contentType, contentEncoding string) error

type File

type File struct {
	Updated time.Time
	// contains filtered or unexported fields
}

func (*File) Reader

func (file *File) Reader() (io.ReadCloser, error)

type Object

type Object struct {
	Path      string
	CreatedAt time.Time
}

Jump to

Keyboard shortcuts

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