check minio

This commit is contained in:
namhq1989 2023-01-08 20:39:17 +07:00
parent 220aeed588
commit f041910455
4 changed files with 14 additions and 6 deletions

2
go.mod
View File

@ -9,7 +9,7 @@ require (
github.com/klauspost/compress v1.15.14 // indirect github.com/klauspost/compress v1.15.14 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect github.com/klauspost/cpuid/v2 v2.2.3 // indirect
github.com/minio/md5-simd v1.1.2 // 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/minio/sha256-simd v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect

2
go.sum
View File

@ -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/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 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.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 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= 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= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=

View File

@ -1,6 +1,7 @@
package minio package minio
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
@ -30,6 +31,10 @@ func Init(cfg Config) (*Client, error) {
fmt.Printf("⚡️[minio]: connected to %s \n", cfg.Endpoint) 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
return &Client{ return &Client{
client: client, client: client,

View File

@ -3,6 +3,7 @@ package minio
import ( import (
"context" "context"
"fmt" "fmt"
"net/url"
"time" "time"
) )
@ -13,14 +14,14 @@ func (c Client) GetPresignedURL(ctx context.Context, bucket, object string, expi
} }
// params // params
//reqParams := make(url.Values) reqParams := make(url.Values)
//reqParams.Set("response-content-disposition", fmt.Sprintf("attachment; filename=\"%s\"", object)) reqParams.Set("response-content-disposition", fmt.Sprintf("attachment; filename=\"%s\"", object))
// get // 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 { if err != nil {
fmt.Printf("[minio.GetPresignedURL][%s] get object %s error: %s \n", bucket, object, err.Error()) fmt.Printf("[minio.GetPresignedURL][%s] get object '%s' error: %s \n", bucket, object, err.Error())
//fmt.Printf("params %v \n", reqParams) fmt.Printf("params %v \n", reqParams)
return "" return ""
} }