简体   繁体   English

如何在 nodeJS 应用程序中使用 Amazon S3?

[英]How to use Amazon S3 inside a nodeJS app?

I am trying to use Amazon S3 to upload/download some images and videos from inside my locally running NodeJS application.我正在尝试使用 Amazon S3 从本地运行的 NodeJS 应用程序中上传/下载一些图像和视频。 But when I search for that, there are tons of different code snippets and different credential management approaches and I am totally confused by that.但是当我搜索它时,有大量不同的代码片段和不同的凭证管理方法,我对此感到非常困惑。

I created an IAM user and I have AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_BUCKET_NAME in my .env file but I think it's not a good approach using .env file in my app and it's better I use temporary token credentials .我创建了一个 IAM 用户,我的.env文件中有AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_BUCKET_NAME ,但我认为在我的应用程序中使用.env文件不是一个好方法,我最好使用临时令牌凭证 But I don't know how?但我不知道怎么办?

What is the minimum secure code I can use to do that?我可以使用的最低安全代码是什么?

Read the AWS SDK for JavaScript V3 Developer Guide .阅读JavaScript V3 开发人员指南的 AWS SDK There are many examples and yes - using creds is a standard practice.有很多例子,是的——使用 creds 是一种标准做法。

What's the AWS SDK for JavaScript? JavaScript 的 AWS SDK 是什么?

A topic you should read is https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials.html您应该阅读的主题是https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM