Can an S3 bucket generate its own object key names?

时光怂恿深爱的人放手 提交于 2019-12-12 20:12:32

问题


I'm configuring the Amazon API Gateway as a proxy for an S3 bucket. Ideally, I'd like the client to be able to POST a file to a bucket, have S3 assign it a file name, and then return that name in the response. I don't want to give the client the ability to specify the file name. Is this possible? The documentation for setting up the proxy doesn't mention POST at all, and other POST examples I've found still require the client to specify the key name.


回答1:


No, auto file name generation isn't supported in S3.




回答2:


If you went through Lambda you could insert any custom logic you wanted, including generating the file name of course. The Lambda function could then return the file name through and you could map it to your API Gateway response.




回答3:


S3 can't assign the name, but in the API gateway mapping template you could use any data from the $context object to construct a name.

e.g. $context.requestId would create a unique key name for your S3 key.



来源:https://stackoverflow.com/questions/37607885/can-an-s3-bucket-generate-its-own-object-key-names

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!