cloudstoragefs

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultDNS         = "https://storage.googleapis.com/"
	DefaultWithTimeout = time.Second * 50
)

Functions

func New

func New(config gfs.IAdapterConfig) gfs.IAdapter

Types

type Adapter

type Adapter struct {
	Config *Config
	// contains filtered or unexported fields
}

Adapter api key https://console.cloud.google.com/apis/dashboard

CredentialsFile 1. IAM和管理->服务账号->创建账号->密钥->添加密钥->密钥类型json->创建

2. Cloud Storage->创建->指定存储桶的名称【test】->点击桶列表中【test】

https://cloud.google.com/storage/docs/access-control/iam-roles?hl=zh-cn 3. 写入权限:权限->授予访问权限->添加主账号(allUsers)->分配角色(Storage Admin)

https://cloud.google.com/storage/docs/access-control/making-data-public?hl=zh-cn 4. 访问权限:权限->授予访问权限->添加主账号(allUsers)->分配角色(Storage Object Viewer)

func NewGCS

func NewGCS(config *Config) *Adapter

func (*Adapter) Bucket

func (a *Adapter) Bucket(bucket string) gfs.IAdapter

func (*Adapter) Client

func (a *Adapter) Client() (*storage.Client, error)

func (*Adapter) Close

func (a *Adapter) Close()

func (*Adapter) Copy

func (a *Adapter) Copy(source, destination string) (bool, error)

func (*Adapter) CopyObject

func (a *Adapter) CopyObject(source, destination string, deleteSource bool) (bool, error)

func (*Adapter) Delete

func (a *Adapter) Delete(path string) (int64, error)

func (*Adapter) DiskName

func (a *Adapter) DiskName() string

func (*Adapter) Exist

func (a *Adapter) Exist(path string) (bool, error)

func (*Adapter) GetMetadata

func (a *Adapter) GetMetadata(object string) (*storage.ObjectAttrs, error)

func (*Adapter) MimeType

func (a *Adapter) MimeType(path string) (string, error)

func (*Adapter) Move

func (a *Adapter) Move(source, destination string) (bool, error)

func (*Adapter) Read

func (a *Adapter) Read(path string) ([]byte, error)

func (*Adapter) Size

func (a *Adapter) Size(path string) (int64, error)

func (*Adapter) StorageObject

func (a *Adapter) StorageObject(object string) (*storage.ObjectHandle, error)

func (*Adapter) StorageObjectTimeout

func (a *Adapter) StorageObjectTimeout(object string) (*storage.ObjectHandle, context.Context, error)

func (*Adapter) URL

func (a *Adapter) URL(path string) (*url.URL, error)

func (*Adapter) Update

func (a *Adapter) Update(path string, contents []byte) error

func (*Adapter) UpdateStream

func (a *Adapter) UpdateStream(path, resource string) error

func (*Adapter) Write

func (a *Adapter) Write(path string, contents []byte) error

func (*Adapter) WriteReader

func (a *Adapter) WriteReader(path string, reader io.Reader) error

func (*Adapter) WriteStream

func (a *Adapter) WriteStream(path, resource string) error

type Config

type Config struct {
	CDN             string        `json:"cdn" xml:"CDN" yaml:"CDN"`
	Bucket          string        `json:"bucket" xml:"Bucket" yaml:"Bucket"`
	WithTimeout     time.Duration `json:"with_timeout" xml:"WithTimeout" yaml:"WithTimeout"`
	CredentialsFile string        `json:"credentials_file" xml:"CredentialsFile" yaml:"CredentialsFile"`
	CredentialsJSON string        `json:"credentials_json" xml:"CredentialsJSON" yaml:"CredentialsJSON"`
	Option          []option.ClientOption
}

func (*Config) BucketUrl

func (c *Config) BucketUrl() (*url.URL, error)

func (*Config) NewAdapter

func (c *Config) NewAdapter() gfs.IAdapter

func (*Config) URL

func (c *Config) URL(path string) (*url.URL, error)

func (*Config) UseBucket

func (c *Config) UseBucket(bucket string) string

Jump to

Keyboard shortcuts

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