2011年7月20日水曜日

s3のファイルをダウンロードする方法

s3cmd.rbというrubyツールが入っている。のでこれを使う方法。


[root@ip-10-150-183-203 s3sync]# mkdir /etc/s3conf
[root@ip-10-150-183-203 s3sync]# cp -p s3config.yml.example /etc/s3conf/s3config.yml
[root@ip-10-150-183-203 s3sync]# pwd
/home/s3sync

[root@ip-10-150-183-203 s3sync]# vi /etc/s3conf/s3config.yml
aws_access_key_id: 11111111111111111111111
aws_secret_access_key: 222222222222222222222
ssl_cert_dir: /home/user/s3sync/certs





[root@ip-10-150-183-203 s3sync]# s3cmd list
Need a bucket
s3cmd [options] <command> [arg(s)]              version 1.2.6
  --help    -h        --verbose     -v     --dryrun    -n
  --ssl     -s        --debug       -d     --progress
  --expires-in=( <# of seconds> | [#d|#h|#m|#s] )

Commands:
s3cmd  listbuckets  [headers]
s3cmd  createbucket  <bucket>  [constraint (i.e. EU)]
s3cmd  deletebucket  <bucket>  [headers]
s3cmd  list  <bucket>[:prefix]  [max/page]  [delimiter]  [headers]
s3cmd  location  <bucket> [headers]
s3cmd  delete  <bucket>:key  [headers]
s3cmd  deleteall  <bucket>[:prefix]  [headers]
s3cmd  get|put  <bucket>:key  <file>  [headers]
[root@ip-10-150-183-203 s3sync]# s3cmd listbuckets
1-1-16


[root@ip-10-150-183-203 ~]# s3cmd get 1-1-16-1019:coherence-java-3.7.0.0b23397.zip coherence.zip
Permanent redirect received. Try setting AWS_CALLING_FORMAT to SUBDOMAIN
[root@ip-10-150-183-203 ~]#


[root@ip-10-150-183-203 ~]# export AWS_CALLING_FORMAT="SUBDOMAIN"
[root@ip-10-150-183-203 ~]# pwd
/root

[root@ip-10-150-183-203 ~]#
[root@ip-10-150-183-203 ~]#  s3cmd get 1-1-16-1019:coherence-java-3.7.0.0b23397.zip coherence.zip
[root@ip-10-150-183-203 ~]# ls
aws  chef-repo
[root@ip-10-150-183-203 ~]# cd /home/s3sync/
[root@ip-10-150-183-203 s3sync]# ls -ltr
total 24536
-rwxrwxrwx 1 root root     7603 Mar 12  2008 thread_generator.rb
-rwxrwxrwx 1 root root      129 Mar 12  2008 s3config.yml.example
-rwxrwxrwx 1 root root     1002 Mar 12  2008 s3config.rb
-rwxrwxrwx 1 root root     1849 Mar 12  2008 S3encoder.rb
-rwxrwxrwx 1 root root     5699 Mar 12  2008 S3_s3sync_mod.rb
-rwxrwxrwx 1 root root    22263 Mar 12  2008 S3.rb
-rwxrwxrwx 1 root root     5275 Mar 12  2008 README_s3cmd.txt
-rwxrwxrwx 1 root root     3591 Jun 16  2008 HTTPStreaming.rb
-rwxrwxrwx 1 root root     7103 Jun 16  2008 s3try.rb
-rwxrwxrwx 1 root root    15968 Jun 16  2008 README.txt
-rwxrwxrwx 1 root root    28294 Aug 28  2009 s3sync.rb
-rwxrwxrwx 1 root root     9988 Aug 28  2009 s3cmd.rb
-rw-r--r-- 1 root root 12476831 Jul 20 06:50 coherence-jaav-3.7.0.0b23397.zip
-rw-r--r-- 1 root root 12476831 Jul 20 06:53 coherence.zip
[root@ip-10-150-183-203 s3sync]#

s3からダウンロードできた!



あるいは
/etc/s3conf/s3config.yml

AWS_CALLING_FORMAT: SUBDOMAIN
とやってもよい。

0 件のコメント:

コメントを投稿