以下の内容はhttps://rriifftt.hatenablog.com/entry/2018/06/04/144906より取得しました。


boto3 で S3 から指定した prefix のオブジェクトをダウンロードする

というスクリプトを書いたので晒してみます。

gist.github.com

$ python download_s3_objects.py --help
Usage: download_s3_objects.py [OPTIONS]

Options:
  -p, --profile TEXT
  -b, --bucket-name TEXT
  -d, --destination TEXT
  -P, --prefix TEXT
  --help                  Show this message and exit.

こんな感じでファイルが格納されているとして

$ aws s3 ls s3://my-bucket/test/
2018-06-04 14:46:19          0 hige_hoge.txt
2018-06-04 14:46:26          0 hoge_hige.txt
2018-06-04 14:46:23          0 hoge_hoge.txt

以下の様に使います。

$ python download_s3_objects.py --bucket-name my-bucket --prefix test/hoge
downloaded ./hoge_hoge.txt
downloaded ./hoge_hige.txt

なお、新しめの powershell なら Copy-S3Object コマンドレット一発でできそうです。

AWS Tools for PowerShell Reference

追記:

rriifftt.hatenablog.com

以上です!




以上の内容はhttps://rriifftt.hatenablog.com/entry/2018/06/04/144906より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14