简体   繁体   English

是否可以生成允许上传多个唯一对象的单个预签名 URL?

[英]Is it possible to generate a single presigned URL which can allow MULTIPLE unique objects to be uploaded?

I know based on the AWS docs here我知道基于这里的 AWS 文档

https://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html https://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html

that its possible to generate a URL which can can used to它可以生成一个 URL 可以用来

upload a specific object to your bucket特定的object 上传到您的存储桶

and that然后

You can use the presigned URL multiple times, up to the expiration date and time.您可以多次使用预签名的 URL,直至到期日期和时间。

It is also possible to generate a URL (perhaps a base s3 presigned URL) which would allow multiple different unique documents to be uploaded based on a single URL?也可以生成一个 URL(可能是一个基本的 s3 预签名 URL),这将允许基于单个 URL 上传多个不同的唯一文档?

For example, lets imagine a client application would like to upload multiple unique/distinct documents to s3 using some type of presigned URL. I dont necessarily want to force them to get a batch of presigned URLs since that would require much more on the part of the client (they would have to request batch of presigned URLs, rather than a single URL)例如,假设一个客户端应用程序想要使用某种类型的预签名 URL 将多个唯一/不同的文档上传到 s3。我不一定要强迫他们获取一批预签名的 URL,因为这将需要更多客户端(他们将不得不请求一批预签名的 URL,而不是单个 URL)

Here is the flow for a single document upload.这是单个文档上传的流程。

在此处输入图像描述

在此处输入图像描述

What is the simplest known solution for allowing a client to use some type of presigned url to upload multiple documents?允许客户端使用某种类型的预签名 url 上传多个文档的最简单的已知解决方案是什么?

It is possible to upload multiple files with a single pre-signed URL and properly configured 'Starts-with' policy.可以使用单个预签名 URL 和正确配置的“开始于”策略上传多个文件。 Please, refer to the following AWS documentation: Browser-Based Uploads Using POST请参阅以下 AWS 文档: 使用 POST 的基于浏览器的上传

It is also possible to generate a URL (perhaps a base s3 presigned URL) which would allow multiple different unique documents to be uploaded based on a single URL?还可以生成一个 URL(可能是一个基本的 s3 预签名 URL),这将允许基于单个 URL 上传多个不同的唯一文档?

A presigned URL is limited to a single single object key.预签名的 URL 仅限于单个 object 密钥。 You can't, for example, presign a key of foo and then use it to upload foo/bar (because that's a different key).例如,您不能预先签署foo的密钥,然后使用它来上传foo/bar (因为那是不同的密钥)。

That means that, if you want to provide the client with a single pre-signed URL, the client code will have to combine the files itself.这意味着,如果您想为客户端提供单个预签名的 URL,则客户端代码必须自行组合文件。 For example, you require the client to upload a ZIP file, then trigger a Lambda that unpacks the files in that ZIP.例如,您需要客户端上传 ZIP 文件,然后触发 Lambda 将文件解压缩到 ZIP 中。

Another approach is to use the AWS SDK from the client, and use the Assume Role operation to generate temporary access credentials that are restricted to uploading files with a specified prefix using an inline session policy.另一种方法是使用来自客户端的 AWS SDK,并使用Assume Role操作生成临时访问凭证,这些凭证仅限于使用内联 session 策略上传具有指定前缀的文件。

A third approach is to hide the URL requests.第三种方法是隐藏 URL 请求。 You don't say what your client application does, but assuming that you let the user select some number of files, you could simply loop over those files and retrieve a URL for each one without ever letting your user know that's happening.你没有说你的客户端应用程序做了什么,但是假设你让用户 select 一些文件,你可以简单地循环这些文件并为每个文件检索一个 URL 而不会让你的用户知道正在发生的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM