php Amazon S3:什么是 PUT/COPY/POST/LIST 请求?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9241679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:25:24  来源:igfitidea点击:

Amazon S3: What are considered PUT/COPY/POST/LIST request?

phpamazon-s3amazon-web-services

提问by IMB

Kindly confirm if this correct:

请确认这是否正确:

  • PUTis probably uploading files to S3?
  • COPYis probably copying files within S3?
  • PUT可能正在将文件上传到 S3?
  • COPY可能是在 S3 中复制文件?

How about POSTand LIST?

如何POSTLIST

Additional question, is get_bucket_filesize() and get_object_filesize() (from PHP SDK) considered a LIST request?

附加问题,get_bucket_filesize() 和 get_object_filesize()(来自 PHP SDK)是否被视为 LIST 请求?

采纳答案by Viccari

From my experience using S3 (and also from the basics of HTTP protocol and REST), POST is the creation of a new object (in S3, it would be the upload of a new file), and PUT is a creation of a new object or update of an existing object (i.e., creation or update of a file). Additionally, from S3 docs:

根据我使用 S3 的经验(以及 HTTP 协议和 REST 的基础知识),POST 是创建一个新对象(在 S3 中,它将是一个新文件的上传),而 PUT 是一个新对象的创建或更新现有对象(即,创建或更新文件)。此外,来自 S3 文档

POST is an alternate form of PUT that enables browser-based uploads as a way of putting objects in buckets

POST 是 PUT 的另一种形式,它支持基于浏览器的上传,作为将对象放入存储桶的一种方式

Every time you, for example, get the contents of a given S3 bucket, you're running into a LIST operation. You have not asked, but a GET is the download of a file from S3 and DELETE would obviously be the deletion of a file. Of course these assumptions depend on which SDK you are using (it seems you're using the PHP one) and its underlying implementation. My argument is that it is possible to implement a download using a GET, an upload using a PUT or a POST, and so forth.

例如,每次获取给定 S3 存储桶的内容时,您都会遇到 LIST 操作。您没有问过,但是 GET 是从 S3 下载文件,而 DELETE 显然是删除文件。当然,这些假设取决于您使用的 SDK(似乎您使用的是 PHP 的)及其底层实现。我的论点是可以使用 GET 实现下载,使用 PUT 或 POST 实现上传,等等。

Taking a look into S3 REST API, though, I assume get_bucket_filesize() is implemented as a LIST (a GET operation on a bucket brings, along with some more data, the size of each object in the response) and get_object_filesize() is implemented as a GET (using the HEAD operation on a single file also brings its size included in the metadata).

不过,看看S3 REST API,我假设 get_bucket_filesize() 是作为 LIST 实现的(对存储桶的 GET 操作带来了响应中每个对象的大小以及更多数据)并实现了 get_object_filesize()作为 GET(对单个文件使用 HEAD 操作也会使其大小包含在元数据中)。

回答by Upul Doluweera

There is not much of a difference between PUT and POST. The following was copied from AWS S3 documentation.

PUT 和 POST 之间没有太大区别。以下内容是从 AWS S3 文档中复制的。

POST is an alternate form of PUTthat enables browser-based uploads as a way of putting objects in buckets. Parameters that are passed to PUT via HTTP Headers are instead passed as form fields to POSTin the multipart/form-data encoded message body.

POST 是PUT另一种形式,它支持基于浏览器的上传,作为将对象放入存储桶的一种方式。通过 HTTP 标头传递到 PUT 的参数会作为表单字段传递到多部分/表单数据编码的消息正文中的POST

http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html

http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html

As others has specified LIST is for listing objects. You can find all the operations in following link.

正如其他人所指定的 LIST 用于列出对象。您可以在以下链接中找到所有操作。

http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketOps.html

http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketOps.html

回答by MrIce

Yes, you are right. PUT is uploading (specifically one file is one PUT). I was watching for whether PUT was per file or per some packet size which would make it more difficult to price. It is putting a file (without reference to size).

你是对的。PUT 正在上传(特别是一个文件就是一个 PUT)。我一直在观察 PUT 是按文件还是按某些数据包大小,这会使定价变得更加困难。它正在放置一个文件(不参考大小)。

ALSO, COPY indeed is copying files within S3, but there's more. See below. I also found references to POST and LIST; see below.

此外,COPY 确实是在 S3 中复制文件,但还有更多。见下文。我还发现了对 POST 和 LIST 的引用;见下文。

So what I learned about PUT/COPY/POST/LIST and GET Requests while digging in to assess our costs. I'm also including WHERE I discovered it (wanted to get it all from Amazon). All corrections are welcome.

所以我在深入评估我们的成本时学到了 PUT/COPY/POST/LIST 和 GET 请求。我还包括我发现它的地方(想从亚马逊获得)。欢迎所有更正。

Amazon's FAQ is here: https://aws.amazon.com/s3/faqs/and I'll reference this below.

亚马逊的常见问题解答在这里:https: //aws.amazon.com/s3/faqs/,我将在下面引用。

COPY can be several things, one of which is copying between regions which does cost. For example, if you store in West VA, and COPY to the Northern CA region, that incurs cost. Copying from EC2 to S3 (within the same region I presume) incurs no transfer cost. See Amazon's FAQ in the section Q: How much does Amazon S3 cost?

COPY 可以是几件事,其中之一是在需要花费的区域之间进行复制。例如,如果您存储在西弗吉尼亚州,然后复制到北加州地区,则会产生成本。从 EC2 复制到 S3(在我假设的同一区域内)不会产生传输成本。请参阅问题部分中的亚马逊常见问题:Amazon S3 的成本是多少?

NOTE: Writing a file, then re-writing that same file stores both versions (unless you delete something). I'm guessing you are not charged more if the files are exactly the same, but don't send me the bill if I'm wrong. :-) It seems that the average size (for a month) is what is billed. See FAQ (link above)

注意:写一个文件,然后重写同一个文件存储两个版本(除非你删除了一些东西)。如果文件完全相同,我猜您不会被收取更多费用,但如果我错了,请不要将帐单寄给我。:-) 似乎平均大小(一个月)是收费的。请参阅常见问题解答(上面的链接)

For PUT, GET and DELETE, it appears one file is one transaction. That answers a big question for me (I didn't want their 128k minimum size to be a PUT for each 128k packet… yeah, I'm paranoid). See the Question section like this:

对于 PUT、GET 和 DELETE,似乎一个文件就是一个事务。这对我来说回答了一个大问题(我不希望它们的 128k 最小大小成为每个 128k 数据包的 PUT……是的,我很偏执)。请参阅问题部分,如下所示:

Q: How will I be charged and billed for my use of Amazon S3?

Request Example:

Assume you transfer 10,000 files into Amazon S3 and transfer 20,000 files out of Amazon S3 each day during the month of March. Then, you delete 5,000 files on March 31st.

Total PUT requests = 10,000 requests x 31 days = 310,000 requests

Total GET requests = 20,000 requests x 31 days = 620,000 requests

Total DELETE requests = 5,000×1 day = 5,000 requests

问:我将如何因使用 Amazon S3 而被收费和计费?

请求示例:

假设您在 3 月份每天将 10,000 个文件传输到 Amazon S3 并从 Amazon S3 传输 20,000 个文件。然后,您在 3 月 31 日删除了 5,000 个文件。

PUT 请求总数 = 10,000 个请求 x 31 天 = 310,000 个请求

GET 请求总数 = 20,000 个请求 x 31 天 = 620,000 个请求

DELETE 请求总数 = 5,000×1 天 = 5,000 个请求

LIST is mentioned under the question: Q: Can I use the Amazon S3 APIs or Management Console to list objects that I've archived to Amazon Glacier? It is essentially getting a list of files… a directory, if you will.

问题下提到了 LIST: 问:我可以使用 Amazon S3 API 或管理控制台列出我已存档到 Amazon Glacier 的对象吗?它本质上是获取一个文件列表……一个目录,如果你愿意的话。

POST is mentioned under RESTObjectPost.html here: http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html

POST 在 RESTObjectPost.html 下提到:http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html

I hope that helps. It sure made me more comfortable with what we would be charged.

我希望这有帮助。这确实让我对我们将收取的费用感到更加满意。