fix content type for video
This commit is contained in:
parent
ce13b7762f
commit
0089757f02
|
@ -11,3 +11,9 @@ var Buckets = struct {
|
||||||
var listBuckets = []string{
|
var listBuckets = []string{
|
||||||
Buckets.HelpCenter,
|
Buckets.HelpCenter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ListTypes = struct {
|
||||||
|
Video string
|
||||||
|
}{
|
||||||
|
Video: "video",
|
||||||
|
}
|
||||||
|
|
|
@ -4,10 +4,11 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
"time"
|
"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
|
// default 15 min
|
||||||
if expiry == 0 {
|
if expiry == 0 {
|
||||||
expiry = 15 * time.Minute
|
expiry = 15 * time.Minute
|
||||||
|
@ -17,6 +18,12 @@ func (c Client) GetPresignedURL(ctx context.Context, bucket, object string, expi
|
||||||
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))
|
||||||
|
|
||||||
|
// 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
|
// get
|
||||||
presignedURL, err := c.client.PresignedGetObject(ctx, bucket, object, expiry, reqParams)
|
presignedURL, err := c.client.PresignedGetObject(ctx, bucket, object, expiry, reqParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue