From f0419104552199116f2bc6ed94ceeedff910bf4b Mon Sep 17 00:00:00 2001 From: namhq1989 Date: Sun, 8 Jan 2023 20:39:17 +0700 Subject: [PATCH] check minio --- go.mod | 2 +- go.sum | 2 ++ minio.go | 5 +++++ presigned_url.go | 11 ++++++----- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 481eb25..c4898b5 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/klauspost/compress v1.15.14 // indirect github.com/klauspost/cpuid/v2 v2.2.3 // indirect github.com/minio/md5-simd v1.1.2 // indirect - github.com/minio/minio-go/v7 v7.0.45 // indirect + github.com/minio/minio-go/v7 v7.0.46 // indirect github.com/minio/sha256-simd v1.0.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect diff --git a/go.sum b/go.sum index 9c230a4..9ac171e 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= github.com/minio/minio-go/v7 v7.0.45 h1:g4IeM9M9pW/Lo8AGGNOjBZYlvmtlE1N5TQEYWXRWzIs= github.com/minio/minio-go/v7 v7.0.45/go.mod h1:nCrRzjoSUQh8hgKKtu3Y708OLvRLtuASMg2/nvmbarw= +github.com/minio/minio-go/v7 v7.0.46 h1:Vo3tNmNXuj7ME5qrvN4iadO7b4mzu/RSFdUkUhaPldk= +github.com/minio/minio-go/v7 v7.0.46/go.mod h1:nCrRzjoSUQh8hgKKtu3Y708OLvRLtuASMg2/nvmbarw= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/minio.go b/minio.go index 33f0b2b..d5dbb2d 100644 --- a/minio.go +++ b/minio.go @@ -1,6 +1,7 @@ package minio import ( + "context" "errors" "fmt" @@ -30,6 +31,10 @@ func Init(cfg Config) (*Client, error) { fmt.Printf("⚡️[minio]: connected to %s \n", cfg.Endpoint) + buckets, err := client.ListBuckets(context.Background()) + fmt.Println("buckets", buckets) + fmt.Println("err", err) + // return return &Client{ client: client, diff --git a/presigned_url.go b/presigned_url.go index 2a02fc8..71b7d4f 100644 --- a/presigned_url.go +++ b/presigned_url.go @@ -3,6 +3,7 @@ package minio import ( "context" "fmt" + "net/url" "time" ) @@ -13,14 +14,14 @@ func (c Client) GetPresignedURL(ctx context.Context, bucket, object string, expi } // params - //reqParams := make(url.Values) - //reqParams.Set("response-content-disposition", fmt.Sprintf("attachment; filename=\"%s\"", object)) + reqParams := make(url.Values) + reqParams.Set("response-content-disposition", fmt.Sprintf("attachment; filename=\"%s\"", object)) // get - presignedURL, err := c.client.PresignedGetObject(context.Background(), bucket, object, expiry, nil) + presignedURL, err := c.client.PresignedGetObject(ctx, bucket, object, expiry, reqParams) if err != nil { - fmt.Printf("[minio.GetPresignedURL][%s] get object %s error: %s \n", bucket, object, err.Error()) - //fmt.Printf("params %v \n", reqParams) + fmt.Printf("[minio.GetPresignedURL][%s] get object '%s' error: %s \n", bucket, object, err.Error()) + fmt.Printf("params %v \n", reqParams) return "" }