Golang未签名网址

时间:2019-02-20 21:05:09

标签: go amazon-s3

我有下一个代码可从亚马逊获取URL,但我需要该URL类似于

https://vis3dev.s3.amazonaws.com/359952_1550525274.mp4

而不是

https://vis3dev.s3.amazonaws.com/266295041.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIE4CD00A5BW7WNTQ%2F20190220%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190220T193732Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=ba800af2fb7b314df2f47a589165558ae50264164c686314b6d73eab2975d8f1

func GetFileLink(svc *session.Session) error {
    req, _ := s3.New(svc).GetObjectRequest(&s3.GetObjectInput{
        Bucket: aws.String(AwsBucket),
        Key:    aws.String(NameFile + ".mp4"),
    })

    url, err := req.Presign(15 * time.Minute)

    if err != nil {
        fmt.Print(err)
    }

    fmt.Println(url)

    return err
}

1 个答案:

答案 0 :(得分:0)

acl := "public-read"

我通过添加ACL: aws.String(acl),

修复了更改上传文件的问题