aliyun

package
v0.0.0-...-aef9ba6 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: MIT Imports: 10 Imported by: 0

README

Aliyun

Aliyun backend for QOR OSS

Usage

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

func main() {
  storage := aliyun.New(&aliyun.Config{
    AccessID:  "access_id",
    AccessKey: "access_id",
    Bucket:    "bucket",
    Endpoint:  "oss-cn-hangzhou.aliyuncs.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 {
	*aliyun.Bucket
	Config *Config
}

Client Aliyun storage

func New

func New(config *Config) *Client

New initialize Aliyun storage

func (Client) Delete

func (client Client) Delete(path string) error

Delete delete file

func (Client) Get

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

Get receive file with given path

func (Client) GetEndpoint

func (client Client) GetEndpoint() string

GetEndpoint get endpoint, FileSystem's endpoint is /

func (Client) GetStream

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

GetStream get 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 list all objects under current path

func (Client) Put

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

Put store a reader into given path

func (Client) ToRelativePath

func (client Client) ToRelativePath(urlPath string) string

ToRelativePath process path to relative path

type Config

type Config struct {
	AccessID      string
	AccessKey     string
	Region        string
	Bucket        string
	Endpoint      string
	ACL           aliyun.ACLType
	ClientOptions []aliyun.ClientOption
	UseCname      bool
}

Config Aliyun client config

Jump to

Keyboard shortcuts

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