文件已成功上传,我要在上传后返回文件url。
_, err := s3.New(s).PutObject(&s3.PutObjectInput{
Bucket: aws.String("bucket"),
Key: aws.String(tempFileName),
ACL: aws.String("public-read"), // could be private if you want it to be access by only authorized users
Body: bytes.NewReader(buffer),
ContentLength: aws.Int64(int64(size)),
ContentType: aws.String(http.DetectContentType(buffer)),
ContentDisposition: aws.String("attachment"),
ServerSideEncryption: aws.String("AES256"),
StorageClass: aws.String("INTELLIGENT_TIERING"),
})
我已经检查了Amazon文档的PutObject函数,但是PutObjectOutput结构类型 但是此结构中没有上传的文件网址。
如何获取文件网址? 上载成功后,还有其他方法可在Amazon s3 sdk中返回上载的文件url吗?
谢谢
分析解答
您可以将URL构造为:
https://BUCKETNAME.s3-REGIONNAME.amazonaws.com/KEY
例如:
https://my-bucket.s3-ap-southeast-2.amazonaws.com/foo/bar.txt