diff --git a/constant.go b/constant.go index 70a6ca3..5979da4 100644 --- a/constant.go +++ b/constant.go @@ -13,7 +13,11 @@ var listBuckets = []string{ } var ListTypes = struct { + File string + Photo string Video string }{ + File: "file", + Photo: "photo", Video: "video", } diff --git a/presigned_url.go b/presigned_url.go index 052adc6..808d9b2 100644 --- a/presigned_url.go +++ b/presigned_url.go @@ -3,6 +3,7 @@ package minio import ( "context" "fmt" + "net/url" "time" ) @@ -13,21 +14,18 @@ func (c Client) GetPresignedURL(ctx context.Context, bucket, object, fileType st } // params - //reqParams := make(url.Values) - // - //// add content type for video - //if fileType == ListTypes.Video { - // parts := strings.Split(object, ".") - // reqParams.Set("response-content-type", fmt.Sprintf("video/%s", parts[len(parts)-1])) - //} else { - // reqParams.Set("response-content-disposition", fmt.Sprintf("attachment; filename=\"%s\"", object)) - //} + reqParams := make(url.Values) + + // set name for type "file" + if fileType == ListTypes.File { + reqParams.Set("response-content-disposition", fmt.Sprintf("attachment; filename=\"%s\"", object)) + } // get - presignedURL, err := c.client.PresignedGetObject(ctx, 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("params %v \n", reqParams) return "" }