amazon-web-services - 如何使用访问 key ID和 secret 访问 key 将文件上传到Amazon S3

标签 amazon-web-services amazon-s3

我必须将一些静态HTML和CSS文件上传到Amazon S3,并且已获得访问 key ID以及 secret 访问 key 。

我已经注册了AWS,如何上传内容?

最佳答案

如果您习惯使用命令行,那么与(几乎)所有AWS交互的最通用(和启用)方法是使用出色的AWS Command Line Interface (AWS CLI)-同时涵盖大多数服务的API,并且它还具有更高级别的S3命令,轻松处理您的用例,请参阅AWS CLI reference for S3(较低级的命令在s3api中)-特别是您可能对以下内容感兴趣:

  • cp-将本地文件或S3对象复制到本地或S3中的另一个位置
  • sync-同步目录和S3前缀。

  • 我使用后者通过简单地同步更改,方便和快速来部署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/

    相关文章:

    ruby - AWS Ruby 开发工具包核心 : Upload files to S3

    mysql - 错误 : Table may not exist or is unsupported relation type code: 25350 context: query: 0 location: mysqlclient. cpp:255 进程:padbmaster [pid=15091]

    node.js - 无法调用我的 lambda 函数

    java - 如何使用java通过TransferManager在S3上上传文件时使文件权限为 "read public"?

    java - 通过 html 文件字段将图像文件上传到我的 aws s3 存储桶

    json - 当我尝试从 R 中的 JSON 文件中提取数据时出现问题

    linux - 不使用 KeyPair 无法连接到 Ubuntu ami

    postgresql - 亚马逊 Redshift : Copying Data Between Databases

    amazon-web-services - 如何将AMI文件存储到S3存储桶?

    mysql - 在 aws 上部署 java 应用程序