googlecloud

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 11 Imported by: 2

README

Google Cloud

Google Cloud backend for QOR OSS

Usage

import "github.com/qor/oss/googlecloud"

func main() {
  storage := googlecloud.New(&qiniu.Config{
    AccessID:  "access_id",
    AccessKey: "access_key",
    Bucket:    "bucket",
    Endpoint:  "https://console.cloud.google.com/",
  })

  // Save a reader interface into storage
  storage.Put("/sample.txt", reader)

  // Get file with path
  storage.Get("/sample.txt")

  // Get object as io.ReadCloser
  storage.GetStream("/sample.txt")

  // Delete file with path
  storage.Delete("/sample.txt")

  // List all objects under path
  storage.List("/")

  // Get Public Accessible URL (useful if current file saved privately)
  storage.GetURL("/sample.txt")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config       *Config
	BucketHandle *storage.BucketHandle
}

Client Google Cloud Storage

func New

func New(config *Config) (*Client, error)

New initializes Google Cloud Storage

func (Client) Delete

func (client Client) Delete(path string) error

Delete deletes file

func (Client) Get

func (client Client) Get(path string) (file *os.File, err error)

Get receives file with given path

func (Client) GetEndpoint

func (client Client) GetEndpoint() string

func (Client) GetStream

func (client Client) GetStream(path string) (io.ReadCloser, error)

GetStream gets file as stream

func (Client) GetURL

func (client Client) GetURL(path string) (url string, err error)

GetURL get public accessible URL

func (Client) List

func (client Client) List(path string) ([]*oss.Object, error)

List lists all objects under current path

func (Client) Put

func (client Client) Put(urlPath string, reader io.Reader) (*oss.Object, error)

Put stores a reader into given path

func (Client) ToRelativePath

func (client Client) ToRelativePath(urlPath string) string

type Config

type Config struct {
	ServiceAccountJson string
	Bucket             string
	Endpoint           string
}

Config Google Cloud Storage client config

Jump to

Keyboard shortcuts

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