[英]Upload image on AWS S3 through API Gateway hosted on ElasticBeansStalk
I have deployed a REST API on elasticbeanstalk, which uploads the image on s3 bucket.我在 elasticbeanstalk 上部署了一个 REST API,它将图像上传到 s3 存储桶上。
REST API is written in node.js and front end is in Reactjs. REST API写在node.js,前端在Reactjs。
When I called the REST API hosted on elasticbeanstalk, which can upload the file on s3.当我调用 REST API 托管在 elasticbeanstalk 上时,它可以在 s3 上上传文件。 After uploading, the file is accessible and displayed correctly.
上传后,文件可访问并正确显示。
I have also deployed the REST API on my local host, and upload the file.我还在本地主机上部署了 REST API,并上传了文件。 It is working fine.
它工作正常。 The uploaded file is displayed correctly.
上传的文件显示正确。
Alternatively, I have configured API gateway with elasticbeanstalk too.或者,我也使用 elasticbeanstalk 配置了 API 网关。 When I called the same REST API via API gateway and which can upload the file on s3.
当我通过 API 网关调用相同的 REST API 并且可以在 s3 上上传文件时。 After the uploading, the file is available on the bucket but somehow that file is not opened correctly.
上传后,该文件在存储桶中可用,但不知何故无法正确打开该文件。 The file seems corrupt.
该文件似乎已损坏。 It may be an issue with the access policy.
这可能是访问策略的问题。
I also see this issue on the file on one occasion我也曾在文件中看到过这个问题
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>10292CE4C4D62A301</RequestId>
<HostId>XJjQBB3DwB6H0lVkS5cHpj3D9ysTa9tApFaacsklg6MGFEnRwyRWLgnVojM8jY3TpCZ6/NQfMogg=</HostId>
</Error>
This is the file which is displayed correctly.这是正确显示的文件。 It is uploaded by calling the REST API directly from local host or elastic beanstalk.
它是通过直接从本地主机或弹性 beantalk 调用 REST API 上传的。 https://images-for-naradej.s3.amazonaws.com/2021-01-14T23%3A39%3A49.938Z-largebanner.jpg
https://images-for-naradej.s3.amazonaws.com/2021-01-14T23%3A39%3A49.938Z-largebanner.jpg
this is the file which is not displayed.这是未显示的文件。 It is uploaded by calling the API Gateway connected to Elastic beanstalk.
通过调用连接Elastic beanstalk的API Gateway上传。 https://images-for-naradej.s3.amazonaws.com/2021-01-14T23%3A46%3A23.030Z-largebanner.jpg
https://images-for-naradej.s3.amazonaws.com/2021-01-14T23%3A46%3A23.030Z-largebanner.jpg
I am not sure why the file is corrupted or access denied when I upload it via API gateway.我不确定为什么当我通过 API 网关上传文件时文件损坏或访问被拒绝。
Can somebody help me with that?有人可以帮我吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.