Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Wrap ¶
func Wrap(client *minio.Client, bucketName string, options ...WrapOption) bucket.Bucket
Wrap wraps minio client to Maleo bucket implementation.
Client credentials must have permission to write access to target bucket.
If client has permission to list and create bucket, it will be used to check if bucket is not exist on initialization, and create the bucket if it is not exist. If client does not have such permissions, it will be silently ignored.
You may operate how bucket creation and put object operation is executed by providing options.
Example ¶
client, err := minio.New("play.min.io", &minio.Options{ Creds: credentials.NewStaticV4("access_key", "secret_key", ""), Secure: true, }) if err != nil { fmt.Println(err.Error()) return } bkt := maleominio.Wrap(client, "my-bucket") f := strings.NewReader("hello world") file := bucket.NewFile(f, "text/plain; charset=utf-8") for _, result := range bkt.Upload(context.Background(), []bucket.File{file}) { if result.Error != nil { fmt.Println(result.Error.Error()) return } }
Output:
Example (Aws) ¶
// Note the region. It's mandatory. client, err := minio.New("s3.us-east-1.amazonaws.com", &minio.Options{ Creds: credentials.NewStaticV4("access_key", "secret_key", ""), Secure: true, }) if err != nil { fmt.Println(err.Error()) return } bkt := maleominio.Wrap(client, "my-bucket", // add optional "yyyy-mm-dd" folder to all uploaded files. maleominio.WithFilePrefixStringer( maleominio.StringerFunc(func() string { return time.Now().Format("2006-01-02/") }), ), ) f := strings.NewReader("hello world") file := bucket.NewFile(f, "text/plain; charset=utf-8") for _, result := range bkt.Upload(context.Background(), []bucket.File{file}) { if result.Error != nil { fmt.Println(result.Error.Error()) return } }
Output:
Types ¶
type PutObjectOptionFunc ¶
type StringerFunc ¶
type StringerFunc func() string
func (StringerFunc) String ¶
func (s StringerFunc) String() string
type WrapOption ¶
type WrapOption interface {
// contains filtered or unexported methods
}
func WithFilePrefix ¶
func WithFilePrefix(s string) WrapOption
WithFilePrefix sets static prefix for file name.
func WithFilePrefixStringer ¶
func WithFilePrefixStringer(s fmt.Stringer) WrapOption
WithFilePrefixStringer sets dynamic prefix for file name.
func WithMakeBucketOption ¶
func WithMakeBucketOption(opt minio.MakeBucketOptions) WrapOption
WithMakeBucketOption sets make bucket option for Minio if bucket does not exist.
func WithPutObjectOption ¶
func WithPutObjectOption(f PutObjectOptionFunc) WrapOption
WithPutObjectOption sets put object option for Minio.