Collection of key-value storages adapters for Golang
This project is maintained by reddec
github.com/reddec/storages/std/awsstorage
Wrapper around official S3 SDK to work with bucket as a map.
Support AWS or any other S3 capable services like Minio.
Do not forget to import package!
s3://[address:port]/<bucket>[?force-path=true]
Where:
address:port
- optional custom address and port for S3-like storageforce-path=true
- optional (default false) requirements to use S3 buckets as a part of pathbucket
- required name of bucketOther parameters will be loaded from environment (see below)
Example:
s3:///abcd-eafg-xyz-0001
- Amazon S3 to bucket abcd-eafg-xyz-0001
. Important first slash /
!s3://myhost:9000/abcd-eafg-xyz-0001?force-path=true
- Custom (Minio for example) S3 serverCommon properties for configuration from environment variables.
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_REGION
Requires import github.com/aws/aws-sdk-go/aws
AWS S3
config := aws.NewConfig()
config.Credentials = credentials.NewEnvCredentials()
stor, err := awsstorage.New("bucket-name", config)
if err != nil {
panic(err)
}
defer stor.Close()
Minio
config := config.WithEndpoint("minio-endpoint-addr")
config.S3ForcePathStyle = true
config.Credentials = credentials.NewEnvCredentials()
stor, err := awsstorage.New("bucket-name", config)
if err != nil {
panic(err)
}
defer stor.Close()