Amazon S3 wrapper for human
AWS offers a complex and bizarre SDK. We needed a library that would make it easier and faster to use S3.
go-s3fs solves this problem. It wraps the official SDK, making S3 extremely easy to use.
go get -u github.com/mobilusoss/go-s3fs
package main
import (
"fmt"
"github.com/mobilusoss/go-s3fs"
)
func main() {
fs := s3fs.New(&s3fs.Config{
Bucket: "samplebucket",
})
readCloser, err := fs.Get("/file.txt")
if err != nil {
panic("s3 error")
}
buf := new(bytes.Buffer)
if _, err := buf.ReadFrom(*readCloser); err != nil {
panic("io error")
}
text := buf.String()
fmt.Println(text)
}
Connect to MinIO
package main
import (
"fmt"
"github.com/mobilusoss/go-s3fs"
)
func main() {
fs := s3fs.New(&s3fs.Config{
Bucket: "samplebucket",
EnableMinioCompat: true,
Endpoint: "http://127.0.0.1:9000",
EnableIAMAuth: true,
AccessKeyID: "accesskey",
AccessSecretKey: "secretkey",
})
readCloser, err := fs.Get("/file.txt")
if err != nil {
panic("s3 error")
}
buf := new(bytes.Buffer)
if _, err := buf.ReadFrom(*readCloser); err != nil {
panic("io error")
}
text := buf.String()
fmt.Println(text)
}
package main
import (
"github.com/mobilusoss/go-s3fs"
)
func main() {
_ = s3fs.New(&s3fs.Config{
Bucket: "samplebucket",
Domain: "tenantone",
})
}
package main
import (
"github.com/mobilusoss/go-s3fs"
)
func main() {
_ = s3fs.New(&s3fs.Config{
Bucket: "samplebucket",
Namespace: "appone",
Domain: "tenantone",
})
}
MIT