What is the difference between the Amazon S3 API calls GetObject and GetObjectRequest?

huangapple go评论91阅读模式
英文:

What is the difference between the Amazon S3 API calls GetObject and GetObjectRequest?

问题

我是你的中文翻译助手,以下是你要翻译的内容:

我对Amazon S3 API还不熟悉,我正在尝试使用Go构建一个客户端。我对如何编写一个Get函数来从S3存储桶中获取对象感到困惑。API调用的文档对我来说有点混乱,我想知道使用GetObject调用和GetObjectRequest调用之间有什么区别?在什么情况下使用其中之一比另一个更合适?

英文:

I am new to the Amazon S3 API and I am attempting to build a client using Go. I was confused about how I would go about writing a Get function to get an object from an S3 bucket. The documentation for the API calls are a little confusing to me, I am wondering what is the difference between using the GetObject call vs the GetObjectRequest call? And when is it appropriate to use one over the other?

答案1

得分: 3

根据文档

调用服务操作的请求形式,遵循操作名 + Request 的命名模式,提供了一种简单的方式来控制请求何时构建、签名和发送。立即调用请求形式将返回一个请求对象。请求对象的输出是一个结构体指针,在请求成功发送并返回之前是无效的。

因此,如果您希望立即发送请求并等待响应,请使用 GetObject。如果您希望构建请求但稍后再发送它,请使用 GetObjectRequest

对于大多数情况,您可能只需使用 GetObject

英文:

Per the documentation:

> Calling the request form of a service operation, which follows the naming pattern OperationName Request, provides a simple way to control when a request is built, signed, and sent. Calling the request form immediately returns a request object. The request object output is a struct pointer that is not valid until the request is sent and returned successfully.

So, use GetObject if you want to immediately send the request and wait for the response. Use GetObjectRequest if you prefer to construct the request but not send it till later.

For most scenarios, you'd probably just use GetObject.

huangapple
  • 本文由 发表于 2021年6月8日 07:33:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/67879766.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定