Documentation ¶
Overview ¶
Package s3 implement abstract file storage API with Amazon Web Service s3
Index ¶
- Constants
- func New(options ...storage.Option) storage.Manager
- func NewReadSeeker(ctx context.Context, input *s3.GetObjectInput, ...) io.ReadSeeker
- func NewStorager(ctx context.Context, baseURL string, options ...storage.Option) (*storager, error)
- func Provider(options ...storage.Option) (storage.Manager, error)
- type AuthConfig
- type AwsConfigProvider
- type CompletedParts
- type Writer
Examples ¶
Constants ¶
View Source
const Scheme = "s3"
Scheme s3 URL proto scheme
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates s3 manager
Example ¶
package main import ( "context" "fmt" "io" "log" "github.com/viant/afsc/s3" ) func main() { service := s3.New() ctx := context.Background() reader, err := service.OpenURL(ctx, "s3://my-bucket/folder/asset") if err != nil { log.Fatal(err) } defer reader.Close() data, err := io.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, input *s3.GetObjectInput, downloader *s3manager.Downloader, partSize, size int) io.ReadSeeker
NewReadSeeker create a reader seeker
func NewStorager ¶ added in v1.9.3
Types ¶
type AuthConfig ¶
type AuthConfig struct { Key string `json:",omitempty"` Secret string `json:",omitempty"` Region string `json:",omitempty"` AccountID string `json:"-"` Token string `json:"-"` Expiry time.Time `json:"-"` RoleArn string `json:",omitempty"` }
AuthConfig represents an auth config
func NewAuthConfig ¶
func NewAuthConfig(options ...storage.Option) (*AuthConfig, error)
NewAuthConfig returns new auth config from location
Example ¶
package main import ( "context" "fmt" "io" "log" "os" "path" "github.com/viant/afs" "github.com/viant/afs/option" "github.com/viant/afsc/s3" ) func main() { authConfig, err := s3.NewAuthConfig(option.NewLocation(path.Join(os.Getenv("HOME"), ".aws/credentials"))) if err != nil { log.Fatal(err) } ctx := context.Background() // add default import _ "github.com/viant/afsc/s3" service := afs.New() reader, err := service.OpenURL(ctx, "s3://my-bucket/myfolder/asset.txt", authConfig) data, err := io.ReadAll(reader) if err != nil { log.Fatal(err) } fmt.Printf("data: %s\n", data) }
Output:
type AwsConfigProvider ¶
AwsConfigProvider represents aws config provider
type CompletedParts ¶ added in v1.4.0
type CompletedParts []*s3.CompletedPart
func (CompletedParts) Len ¶ added in v1.4.0
func (a CompletedParts) Len() int
func (CompletedParts) Less ¶ added in v1.4.0
func (a CompletedParts) Less(i, j int) bool
func (CompletedParts) Swap ¶ added in v1.4.0
func (a CompletedParts) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.