Documentation ¶
Index ¶
- Constants
- Variables
- func NewClient(conf *cloudstorage.Config) (*az.Client, *az.BlobStorageClient, error)
- type FS
- func (f *FS) Client() interface{}
- func (f *FS) Delete(ctx context.Context, name string) error
- func (f *FS) Folders(ctx context.Context, q cloudstorage.Query) ([]string, error)
- func (f *FS) Get(ctx context.Context, objectpath string) (cloudstorage.Object, error)
- func (f *FS) List(ctx context.Context, q cloudstorage.Query) (*cloudstorage.ObjectsResponse, error)
- func (f *FS) NewObject(objectname string) (cloudstorage.Object, error)
- func (f *FS) NewReader(o string) (io.ReadCloser, error)
- func (f *FS) NewReaderWithContext(ctx context.Context, objectname string) (io.ReadCloser, error)
- func (f *FS) NewWriter(objectName string, metadata map[string]string) (io.WriteCloser, error)
- func (f *FS) NewWriterWithContext(ctx context.Context, name string, metadata map[string]string, ...) (io.WriteCloser, error)
- func (f *FS) Objects(ctx context.Context, q cloudstorage.Query) (cloudstorage.ObjectIterator, error)
- func (f *FS) String() string
- func (f *FS) Type() string
Constants ¶
const ( // StoreType = "azure" this is used to define the storage type to create // from cloudstorage.NewStore(config) StoreType = "azure" // ConfKeyAuthKey config key name of the azure api key for auth ConfKeyAuthKey = "azure_key" // AuthKey is for using azure api key AuthKey cloudstorage.AuthMethod = "azure_key" )
Variables ¶
var ( // Retries number of times to retry upon failures. Retries = 3 // PageSize is default page size PageSize = 2000 // ErrNoAzureSession no valid session ErrNoAzureSession = fmt.Errorf("no valid azure session was created") // ErrNoAccessKey error for no azure_key ErrNoAccessKey = fmt.Errorf("no settings.azure_key") // ErrNoAuth error for no findable auth ErrNoAuth = fmt.Errorf("No auth provided") )
Functions ¶
func NewClient ¶
func NewClient(conf *cloudstorage.Config) (*az.Client, *az.BlobStorageClient, error)
NewClient create new AWS s3 Client. Uses cloudstorage.Config to read necessary config settings such as bucket, region, auth.
Types ¶
type FS ¶
FS Simple wrapper for accessing azure blob files, it doesn't currently implement a Reader/Writer interface so not useful for stream reading of large files yet.
func NewStore ¶
func NewStore(c *az.Client, blobClient *az.BlobStorageClient, conf *cloudstorage.Config) (*FS, error)
NewStore Create AWS S3 storage client of type cloudstorage.Store
func (*FS) Client ¶
func (f *FS) Client() interface{}
Client gets access to the underlying google cloud storage client.
func (*FS) List ¶
func (f *FS) List(ctx context.Context, q cloudstorage.Query) (*cloudstorage.ObjectsResponse, error)
List objects from this store.
func (*FS) NewObject ¶
func (f *FS) NewObject(objectname string) (cloudstorage.Object, error)
NewObject of Type azure.
func (*FS) NewReader ¶
func (f *FS) NewReader(o string) (io.ReadCloser, error)
// Copy from src to destination func (f *FS) Copy(ctx context.Context, src, des cloudstorage.Object) error {
so, ok := src.(*object) if !ok { return fmt.Errorf("Copy source file expected s3 but got %T", src) } do, ok := des.(*object) if !ok { return fmt.Errorf("Copy destination expected s3 but got %T", des) } oh := so.b.Object(so.name) dh := do.b.Object(do.name) _, err := dh.CopierFrom(oh).Run(ctx) return err }
// Move which is a Copy & Delete func (f *FS) Move(ctx context.Context, src, des cloudstorage.Object) error {
so, ok := src.(*object) if !ok { return fmt.Errorf("Move source file expected s3 but got %T", src) } do, ok := des.(*object) if !ok { return fmt.Errorf("Move destination expected s3 but got %T", des) } oh := so.b.Object(so.name) dh := do.b.Object(des.name) if _, err := dh.CopierFrom(oh).Run(ctx); err != nil { return err } return oh.Delete(ctx) }
NewReader create file reader.
func (*FS) NewReaderWithContext ¶
NewReaderWithContext create new File reader with context.
func (*FS) NewWriterWithContext ¶
func (f *FS) NewWriterWithContext(ctx context.Context, name string, metadata map[string]string, opts ...cloudstorage.Opts) (io.WriteCloser, error)
NewWriterWithContext create writer with provided context and metadata.
func (*FS) Objects ¶
func (f *FS) Objects(ctx context.Context, q cloudstorage.Query) (cloudstorage.ObjectIterator, error)
Objects returns an iterator over the objects in the google bucket that match the Query q. If q is nil, no filtering is done.