// Package data provides database interactions to the app package data import ( "context" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) type Client struct { Endpoint, AccessKeyID, SecretAccessKey string UseSSL bool MongoClient *minio.Client Context context.Context } func NewClient(buckets []string, endpoint, accessKeyID, secretAccessKey string, useSSL bool) (*Client, error) { c := Client{ Endpoint: endpoint, AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, UseSSL: useSSL, Context: context.Background(), } // Initialize minio client object mongo_client, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), Secure: useSSL, }) if err != nil { return &c, err } c.MongoClient = mongo_client return &c, nil } func (c *Client) BucketExists(bucketName string) (bool, error) { result, err := c.MongoClient.BucketExists(c.Context, bucketName) if err != nil { return false, err } return result, nil }