gcs

package
v0.0.0-...-dec25df Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package GCS contains the code to interface with Google Cloud Storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseGcsUri

func ParseGcsUri(uri string) (bucket, name string, err error)

ParseGcsUri parses a "gs://" URI into a bucket, name pair. Inspired by: https://github.com/GoogleCloudPlatform/gifinator/blob/master/internal/gcsref/gcsref.go#L37

Types

type Config

type Config struct {
	ProjectId string // Project Id
	Email     string // Email (authentication)
	Key       string // Key (authentication)
	Bucket    string // GCS bucket
}

type GCS

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

func NewGCS

func NewGCS(cfg *Config) *GCS

Create a GCS client.

func (*GCS) DeleteFiles

func (g *GCS) DeleteFiles(uris []string) error

Delete files from GCS.

func (*GCS) GetReader

func (g *GCS) GetReader(name string) (io.ReadCloser, error)

Get a ReaderCloser of a GCS file.

func (*GCS) Insert

func (g *GCS) Insert(ctx context.Context, name string, media io.Reader) (*storage.Object, error)

Create a GCS file. Media is the Reader from which the data will be read and then sent to GCS.

func (*GCS) UrlForName

func (g *GCS) UrlForName(name string) string

Given a file name, return a fully qualified gs:// URL

Jump to

Keyboard shortcuts

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