[英]Hosting images on Lambda + API gateway
I got NodeJS application running on AWS Lambda + API gateway environment. 我让NodeJS应用程序在AWS Lambda + API网关环境上运行。
I am deploying my app via serverless app ( https://www.npmjs.com/package/serverless ). 我正在通过无服务器应用程序( https://www.npmjs.com/package/serverless )部署我的应用程序。 My assets (including images) are packed together to zip format, sent to S3 storage and deployed via cloudfront (regular serverless flow).
我的资产(包括图像)打包成zip格式,发送到S3存储,并通过cloudfront(常规的无服务器流)进行部署。
Requests to images responses with 200 OK status. 请求图像响应状态为200 OK。 The problem is that they are not displaying.
问题在于它们没有显示。 I have no idea where should I start to look for an issue.
我不知道我应该从哪里开始寻找问题。
I enabled binary media types in my API Gateway, and provided following types: image/gif
, image/jpeg
. 我在API网关中启用了二进制媒体类型,并提供了以下类型:
image/gif
, image/jpeg
。
For example I am trying to display this image: http://www.top13.net/wp-content/uploads/2015/10/perfectly-timed-funny-cat-pictures-5.jpg 例如,我试图显示此图像: http : //www.top13.net/wp-content/uploads/2015/10/perfectly-timed-funny-cat-pictures-5.jpg
Here is URL to it in my app: http://angular-universal-serverless.maciejtreder.com/assets/img/cat.jpg 这是我的应用程序中的URL: http : //angular-universal-serverless.maciejtreder.com/assets/img/cat.jpg
Is it even possible to display images this way? 甚至可以通过这种方式显示图像吗? Maybe I should upload them to S3 storage?
也许我应该将它们上传到S3存储?
Here are some entries from logs (before enabling binary media types): 以下是日志中的一些条目(启用二进制媒体类型之前):
http://www.heypasteit.com/clip/0IILRO http://www.heypasteit.com/clip/0IILRO
and after enabling: http://www.heypasteit.com/clip/0IILS2 并启用后: http : //www.heypasteit.com/clip/0IILS2
I have solved problem, by my own. 我自己解决了问题。
Here is boilerplate repository: https://github.com/maciejtreder/angular-universal-serverless 这是样板库: https : //github.com/maciejtreder/angular-universal-serverless
The point was to encode files on Lambda side, and send it in encoded form to API GW with proper headers. 关键是在Lambda端对文件进行编码,然后以编码形式将其发送到具有适当标头的API GW。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.