diff --git a/constant.go b/constant.go index ee9a337..70a6ca3 100644 --- a/constant.go +++ b/constant.go @@ -11,3 +11,9 @@ var Buckets = struct { var listBuckets = []string{ Buckets.HelpCenter, } + +var ListTypes = struct { + Video string +}{ + Video: "video", +} diff --git a/presigned_url.go b/presigned_url.go index 71b7d4f..7cb699c 100644 --- a/presigned_url.go +++ b/presigned_url.go @@ -4,10 +4,11 @@ import ( "context" "fmt" "net/url" + "strings" "time" ) -func (c Client) GetPresignedURL(ctx context.Context, bucket, object string, expiry time.Duration) string { +func (c Client) GetPresignedURL(ctx context.Context, bucket, object, fileType string, expiry time.Duration) string { // default 15 min if expiry == 0 { expiry = 15 * time.Minute @@ -17,6 +18,12 @@ func (c Client) GetPresignedURL(ctx context.Context, bucket, object string, expi reqParams := make(url.Values) reqParams.Set("response-content-disposition", fmt.Sprintf("attachment; filename=\"%s\"", object)) + // add content type for video + if fileType == ListTypes.Video { + parts := strings.Split(object, ".")[1] + reqParams.Set("response-content-type", fmt.Sprintf("video/%s", parts[len(parts)-1])) + } + // get presignedURL, err := c.client.PresignedGetObject(ctx, bucket, object, expiry, reqParams) if err != nil {