![](http://aws-guide.work/wp-content/themes/cocoon-master/images/b-woman.png)
AWS CLIで
・S3上の指定したバケット配下に、
・オブジェクト(ファイルやフォルダ)を作成
できます!
![](http://aws-guide.work/wp-content/themes/cocoon-master/images/b-woman.png)
「aws s3api put-object」コマンドで
取得できます!
サンプルコマンド
ここでは例として
・バケット「tmp12345」配下のフォルダ「sub1」配下に
・フォルダ「folder」とファイル「file.txt」を作成
します。
![バケット「tmp12345」配下のフォルダ「sub1」配下に、フォルダ「folder」とファイル「file.txt」は存在しない](https://aws-guide.work/wp-content/uploads/2024/02/aws_s3api_put-object_001.png)
構文は以下です。
●フォルダを作成する場合
aws s3api put-object --bucket バケット名 --key "フォルダ名/作成するフォルダ名/" --profile プロファイル名
●ファイルを作成する場合
aws s3api put-object --bucket バケット名 --key "フォルダ名/作成するフォルダ名" --profile プロファイル名
実行例は以下です。
●フォルダを作成する場合
aws s3api put-object --bucket tmp12345 --key "sub1/folder/" --profile develop
●ファイルを作成する場合
aws s3api put-object --bucket tmp12345 --key "sub1/file.txt" --profile develop
実行結果
S3上の指定したバケット配下に
・オブジェクト(ファイルやフォルダ)を作成
できました。
※バケット「tmp12345」配下のフォルダ「sub1」配下に、フォルダ「folder」とファイル「file.txt」を作成できました。
![実行結果①](https://aws-guide.work/wp-content/uploads/2024/02/aws_s3api_put-object_002.png)
![実行結果②](https://aws-guide.work/wp-content/uploads/2024/02/aws_s3api_put-object_003.png)
参考
「aws s3api put-object」の詳細は、公式サイトをご確認ください。