gcsimage

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

README

Google Cloud Storage images

This wrapper is based on github.com/disintegration/imaging. Big thanks to @disintegration

Setup

GOOGLE_APPLICATION_CREDENTIALS=gcs_key.json
IMAGES_STORAGE_BUCKET=anthive-img

How to use it

import 	"github.com/devteamclub/gcsimage"

var bucket *gcsimage.Bucket

func main() {
    initImageBucket(context.Background())
	
    // ... //
    id, err := bucket.Add(context.Background(), data)
	
    // ... //
    data, contentType, err := bucket.Get(context.Background(), id, gcsimage.Top, width, height)
}

func initImageBucket(ctx context.Context) {
    var err error
    bucket, err = gcsimage.InitBucket(ctx, os.Getenv("IMAGES_STORAGE_BUCKET"))
    if err != nil {
    panic(err)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anchor

type Anchor int
const (
	Center Anchor = iota
	TopLeft
	Top
	TopRight
	Left
	Right
	BottomLeft
	Bottom
	BottomRight
)

type Bucket

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

func InitBucket

func InitBucket(ctx c.Context, bucketName string) (*Bucket, error)

func (*Bucket) Add

func (b *Bucket) Add(ctx c.Context, data []byte) (string, error)

func (*Bucket) Get

func (b *Bucket) Get(ctx c.Context, id string, anchor Anchor, width, height int) (data []byte, contentType string, err error)

func (*Bucket) Save

func (b *Bucket) Save(ctx c.Context, key string, data []byte) error

Jump to

Keyboard shortcuts

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