Issue
File is uploaded successfully, and I want to return file url after uploading.
_, 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"),
})
I have checked amazon doc for PutObject function, but PutObjectOutput struct type But there is no uploaded file url in this structure.
How can I get file url? Is there other way to return uploaded file url in amazon s3 sdk as soon as upload success?
Thanks
Solution
You can construct the URL as:
https://BUCKETNAME.s3-REGIONNAME.amazonaws.com/KEY
For example:
https://my-bucket.s3-ap-southeast-2.amazonaws.com/foo/bar.txt
Answered By - John Rotenstein Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.