本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/s3.S3.GetObjectRequest方法的典型用法代碼示例。如果您正苦於以下問題:Golang S3.GetObjectRequest方法的具體用法?Golang S3.GetObjectRequest怎麽用?Golang S3.GetObjectRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aws/aws-sdk-go/service/s3.S3
的用法示例。
在下文中一共展示了S3.GetObjectRequest方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
Body: file,
})
if err != nil {
return
}
}
}
return
}
var downloadFileHandler = func(w http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
bucketName := vars["dir"]
fileName := vars["file"]
s3req, _ := s3Client.GetObjectRequest(&s3.GetObjectInput{
Bucket: aws.String(conf.S3.BucketName),
Key: aws.String(bucketName + "/" + fileName),
})
presigned, err := s3req.Presign(time.Minute * 10)
if err != nil {
http.Error(w, err.Error(), 503)
}
http.Redirect(w, req, presigned, 307)
}
var unauthorizedHandler = func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("WWW-Authenticate", fmt.Sprintf(`Basic realm=%q`, "WebRTC Logs"))
w.WriteHeader(401)
w.Write([]byte("Unauthorized"))