TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What is the best way to Upload Images to AWS S3?

5 点作者 fuadnafiz98将近 3 年前
I am building a full stack Nodejs, Express.js and React application with a file upload functionality.<p>What will be the best approach to upload the file?<p>1. Upload the file from frontend to S3? 2. First upload the file to backend and then upload the file from backend to S3?<p>What will be the best option? In my opinion the first approach is better as it doesn&#x27;t require extra load on backend if the file is larger, but I am not sure about the security issues to keep the AWS credentials in the frontend code.<p>Any suggestions are welcome :)

3 条评论

danenania将近 3 年前
This is the best way that I know of:<p><a href="https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;AmazonS3&#x2F;latest&#x2F;userguide&#x2F;PresignedUrlUploadObject.html" rel="nofollow">https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;AmazonS3&#x2F;latest&#x2F;userguide&#x2F;Presig...</a>
评论 #31908218 未加载
mr_gibbins将近 3 年前
I don&#x27;t have a specific best-practice answer but you could invoke a back-end method which fetches the AWS credentials from Secrets Manager (using a baked-in access key), thereby hiding them from the front-end?<p>Worth taking a look at the AWS WAF (Well-Architected Framework) as this will give you some AWS-approved architecture ideas.
评论 #31867261 未加载
codegeek将近 3 年前
You need to have server side code for sure. The frontend should just send the file to the backend URL to process. The backend should take care of the logic to upload to S3 (and validations etc as needed). Do not store AWS credentials anywhere on the front end.