oss

package module
v0.0.0-...-8411d4f Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 7 Imported by: 5

README

OSS

QOR OSS provide common interface to operate files in cloud storage, ftp, filesystem...

Usage

import (
	"github.com/oss/filesystem"
	"github.com/oss/s3"
	awss3 "github.com/aws/aws-sdk-go/s3"
)

func main() {
	storage := s3.New(s3.Config{AccessID: "access_id", AccessKey: "access_key", Region: "region", Bucket: "bucket", Endpoint: "cdn.getqor.com", ACL: awss3.BucketCannedACLPublicRead})
	// storage := filesystem.New("/tmp")

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

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

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAssetFsUnavailable = errors.New("asset fs unavailable")

Functions

func IsErrAssetFsUnavailable

func IsErrAssetFsUnavailable(err error) bool

Types

type Endpoint

type Endpoint struct {
	Scheme string
	Host   string
	Path   string
}

func (*Endpoint) DinamicURL

func (ep *Endpoint) DinamicURL(scheme, host string) string

func (*Endpoint) URL

func (ep *Endpoint) URL() string

type NameGetter

type NameGetter func(name string) string

type NamedStorage

type NamedStorage struct {
	StorageInterface
	StorageName string
}

func (*NamedStorage) Name

func (ns *NamedStorage) Name() string

type NamedStorageInterface

type NamedStorageInterface interface {
	StorageInterface
	Name() string
}

type Names

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

func NewNames

func NewNames() *Names

func (*Names) Alias

func (names *Names) Alias(real, alias string, aliases ...string) error

func (*Names) Get

func (names *Names) Get(key string) (name string)

Get used to get storage name with key

func (*Names) GetOrDefault

func (names *Names) GetOrDefault(key string, defauls ...string) (name string)

func (*Names) Getter

func (names *Names) Getter(getter NameGetter) *Names

func (*Names) Set

func (names *Names) Set(key, value string) *Names

Get used to set option with name

type Object

type Object struct {
	Path             string
	Name             string
	LastModified     *time.Time
	StorageInterface StorageInterface
}

Object content object

func (Object) Get

func (object Object) Get() (*os.File, error)

Get retrieve object's content

type StorageInterface

type StorageInterface interface {
	http.Handler
	Stat(path string) (info os.FileInfo, notFound bool, err error)
	Get(path string) (*os.File, error)
	Put(path string, reader io.Reader) (*Object, error)
	Delete(path string) error
	List(path string) ([]*Object, error)
	GetEndpoint() *Endpoint
	GetURL(p ...string) string
	GetDynamicURL(scheme, host string, p ...string) (url string)
	AssetFS() (assetfsapi.Interface, error)
}

StorageInterface define common API to operate storage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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