我必须将一些静态HTML和CSS文件上传到Amazon S3,并且已获得访问 key ID以及 secret 访问 key 。
我已经注册了AWS,如何上传内容?
最佳答案
如果您习惯使用命令行,那么与(几乎)所有AWS交互的最通用(和启用)方法是使用出色的AWS Command Line Interface (AWS CLI)-同时涵盖大多数服务的API,并且它还具有更高级别的S3命令,轻松处理您的用例,请参阅AWS CLI reference for S3(较低级的命令在s3api中)-特别是您可能对以下内容感兴趣:
我使用后者通过简单地同步更改,方便和快速来部署static websites hosted on S3。您的用例由Examples的第一个覆盖(可以使用
--exclude
,--include
和前缀处理等更精细的用法):The following sync command syncs objects under a specified prefix and bucket to files in a local directory by uploading the local files to s3. [...]
aws s3 sync . s3://mybucket
虽然AWS CLI通过环境变量支持常规的AWS Credentials处理,但您也可以为自己和其他AWS账户配置Multiple Configuration Profiles并根据需要进行切换:
The AWS CLI supports switching between multiple profiles stored within the configuration file. [...] Each profile uses different credentials—perhaps from two different IAM users—and also specifies a different region. The first profile, default, specifies the region us-east-1. The second profile, test-user, specifies us-west-2. Note that, for profiles other than default, you must prefix the profile name with the string, profile.
关于amazon-web-services - 如何使用访问 key ID和 secret 访问 key 将文件上传到Amazon S3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23784561/