Documentation ¶
Overview ¶
Package gs implements abstract file storage API with Google Storage
Index ¶
- Constants
- Variables
- func GetListCounter(reset bool) int
- func GetRetryCodes(reset bool) map[int]int
- func HasAuthOption(options []option.ClientOption) bool
- func New(options ...storage.Option) storage.Manager
- func NewReadSeeker(ctx context.Context, storager *storager, call *storage.ObjectsGetCall, ...) io.ReadSeeker
- func NewStorager(ctx context.Context, baseURL string, options ...storage.Option) (storage.Storager, error)
- func Options(base, options []option.ClientOption) []option.ClientOption
- func Provider(options ...storage.Option) (storage.Manager, error)
- func SetCustomKeyHeader(key *option.AES256Key, headers http.Header) error
- func SetOptions(options ...goptions.ClientOption)
- type ClientOptions
- type Project
- type Scopes
Examples ¶
Constants ¶
View Source
const ( //UserAgent defines this library user agent UserAgent = "viant/gcpgs" //DefaultUploadChunkSize default upload chunk size DefaultUploadChunkSize = 16 * 1024 * 1024 )
View Source
const Scheme = "gs"
Scheme represents google storage scheme
Variables ¶
View Source
var DefaultHTTPClientProvider = getDefaultHTTPClient
DefaultHTTPClientProvider defaultHTTP client
View Source
var DefaultOptions []goptions.ClientOption
DefaultOptions represents default client option
View Source
var DefaultProjectProvider = getDefaultProject
DefaultProjectProvider default projectid provider
Functions ¶
func GetListCounter ¶ added in v0.9.4
GetListCounter returns count of list operations
func GetRetryCodes ¶ added in v0.11.2
func HasAuthOption ¶ added in v1.9.2
func HasAuthOption(options []option.ClientOption) bool
func New ¶
New creates scp manager
Example ¶
package main import ( "context" "fmt" "github.com/viant/afsc/gs" "io/ioutil" "log" ) func main() { service := gs.New() ctx := context.Background() reader, err := service.OpenURL(ctx, "gs://my-bucket/folder/asset") if err != nil { log.Fatal(err) } defer reader.Close() data, err := ioutil.ReadAll(reader) if err != nil { log.Fatal(err) } fmt.Printf("data: %s\n", data) }
Output:
func NewReadSeeker ¶ added in v0.6.0
func NewReadSeeker(ctx context.Context, storager *storager, call *storage.ObjectsGetCall, size int) io.ReadSeeker
NewReadSeeker create a reader seeker
func NewStorager ¶
func NewStorager(ctx context.Context, baseURL string, options ...storage.Option) (storage.Storager, error)
NewStorager returns new storager
func Options ¶ added in v1.9.2
func Options(base, options []option.ClientOption) []option.ClientOption
func SetCustomKeyHeader ¶
SetCustomKeyHeader set encryption headers
func SetOptions ¶ added in v1.9.0
func SetOptions(options ...goptions.ClientOption)
SetOptions set global default options
Types ¶
type ClientOptions ¶
type ClientOptions []option.ClientOption
ClientOptions represents gcp client options
func NewClientOptions ¶
func NewClientOptions(options ...option.ClientOption) ClientOptions
NewClientOptions creates an option slice
Example ¶
package main import ( "context" "encoding/json" "fmt" "github.com/viant/afs" "github.com/viant/afs/option" "github.com/viant/afsc/auth" "github.com/viant/afsc/gs" goption "google.golang.org/api/option" "io/ioutil" "log" "os" "path" ) func main() { secretPath := path.Join(os.Getenv("HOME"), ".secret", "gcp-e2e.json") jwtConfig, err := auth.NewJwtConfig(option.NewLocation(secretPath)) if err != nil { log.Fatal(err) } ctx := context.Background() JSON, err := json.Marshal(jwtConfig) jsonAuth := goption.WithCredentialsJSON(JSON) service := afs.New() reader, err := service.OpenURL(ctx, "gs://my-bucket/myfolder/asset.txt", gs.NewClientOptions(jsonAuth), gs.NewProject("myproject")) data, err := ioutil.ReadAll(reader) if err != nil { log.Fatal(err) } fmt.Printf("data: %s\n", data) }
Output:
Click to show internal directories.
Click to hide internal directories.