[英]API Gateway - Read file from S3 which just created by a lambda function on the same rest endpoint
I have created a lambda function to convert a file on S3 and put the new converted file back to S3, the lambda function is triggered by rest api on api gateway. I have created a lambda function to convert a file on S3 and put the new converted file back to S3, the lambda function is triggered by rest api on api gateway. What I want to do is to reply the client by that same converted file when accessing the same endpoint.
我想要做的是在访问同一个端点时通过同一个转换文件回复客户端。 The option that I have in my mind is to return the file from lambda, which may not be a time optimized solution.
我的想法是从 lambda 返回文件,这可能不是时间优化的解决方案。 My question is there another possible solution?
我的问题是还有另一种可能的解决方案吗? like calling the lambda function and forward the request to the created object in S3?
就像调用 lambda function 并将请求转发到 S3 中创建的 object 一样? I thought of forwarding one api resource to another one which will read from S3 directly, is it possible somehow?
我想将一个 api 资源转发到另一个将直接从 S3 读取的资源,这可能吗?
You probably want to return a pre-signed S3 url for the file you've just created, which the client can then follow (at most once, and for a limited time), to download that file directly from S3.您可能希望为您刚刚创建的文件返回一个预签名的 S3 url,然后客户端可以按照该文件(最多一次,并且在有限的时间内)直接从 S3 下载该文件。 The general documentation is here , but there will probably be a helper for it in an SDK for whatever language you're using.
一般文档在这里,但是对于您使用的任何语言,SDK 中可能会有一个帮助程序。
Remember that API Gateway has a maximum timeout of 29 seconds.请记住,API 网关的最大超时时间为 29 秒。 This is probably fine if you're just moving small amounts of data around in S3, but it's worth being aware of!
如果您只是在 S3 中移动少量数据,这可能很好,但值得注意!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.