Documentation ¶
Index ¶
- Variables
- func New(config gfs.IAdapterConfig) gfs.IAdapter
- type Adapter
- func (a *Adapter) Bucket(bucket string) gfs.IAdapter
- func (a *Adapter) Client() (*storage.Client, error)
- func (a *Adapter) Close()
- func (a *Adapter) Copy(source, destination string) (bool, error)
- func (a *Adapter) CopyObject(source, destination string, deleteSource bool) (bool, error)
- func (a *Adapter) Delete(path string) (int64, error)
- func (a *Adapter) DiskName() string
- func (a *Adapter) Exist(path string) (bool, error)
- func (a *Adapter) GetMetadata(object string) (*storage.ObjectAttrs, error)
- func (a *Adapter) MimeType(path string) (string, error)
- func (a *Adapter) Move(source, destination string) (bool, error)
- func (a *Adapter) Read(path string) ([]byte, error)
- func (a *Adapter) Size(path string) (int64, error)
- func (a *Adapter) StorageObject(object string) (*storage.ObjectHandle, error)
- func (a *Adapter) StorageObjectTimeout(object string) (*storage.ObjectHandle, context.Context, error)
- func (a *Adapter) URL(path string) (*url.URL, error)
- func (a *Adapter) Update(path string, contents []byte) error
- func (a *Adapter) UpdateStream(path, resource string) error
- func (a *Adapter) Write(path string, contents []byte) error
- func (a *Adapter) WriteReader(path string, reader io.Reader) error
- func (a *Adapter) WriteStream(path, resource string) error
- type Config
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultDNS = "https://storage.googleapis.com/" DefaultWithTimeout = time.Second * 50 )
Functions ¶
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 (*Adapter) CopyObject ¶
func (*Adapter) GetMetadata ¶
func (a *Adapter) GetMetadata(object string) (*storage.ObjectAttrs, error)
func (*Adapter) StorageObject ¶
func (a *Adapter) StorageObject(object string) (*storage.ObjectHandle, error)
func (*Adapter) StorageObjectTimeout ¶
func (*Adapter) UpdateStream ¶
func (*Adapter) WriteStream ¶
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) NewAdapter ¶
Click to show internal directories.
Click to hide internal directories.