问题
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