AWS S3
package main
import (
"context"
"github.com/joshqu1985/fireman/configor"
"github.com/joshqu1985/fireman/store/s3"
)
type Config struct {
S3 s3.Config
}
var (
Conf Config
)
func init() {
if err := configor.Load("./configs/conf.toml", &Conf); err != nil {
panic(err)
}
}
func main() {
pool := s3.NewPool(Conf.S3)
var data []byte
handle := func(client *s3.S3Client) error {
_, err := client.Client.PutObject(&s3.PutObjectInput{
Key: aws.String("/image/original/1.jpg"),
Body: bytes.NewReader(data),
Bucket: aws.String(client.Bucket),
ACL: aws.String(client.ACL),
ContentType: aws.String("image/jpeg"),
})
return err
}
err := pool.Doit(context.Background(), "image", handle)
fmt.Prinln(err)
}
#conf.toml
[s3]
host = "us-east-2"
[[s3.buckets]]
acl = "private"
bucket = "image"