LoginSignup
1
1

More than 5 years have passed since last update.

RからS3にアクセスしたい

Posted at

環境は、AWS上のUbunutuから。

試行錯誤しながらやったので、余分なものも入ってるかも。

RS3ライブラリを使います。

OS側

curlとsslライブラリ関連を入れます。必要に応じてbuild-essentialも入れてください。

$ sudo apt-get install libxml2-dev libcurl3-dev libcurl4-openssl-dev

R側

install.packages("git2r")
install.packages("devtools")
reuqire("devtools")
install_github("Gastrograph/RS3")

devtoolsのインストールの時に何故か、git2rでコケたので別途入れていますが、devtoolsだけで、インストールされるはず。

/usr/lib/Rだが、/usr/local/lib/Rだかの権限がないと怒られるので、適当にゴニョる。

実行

require("RS3")
S3_connect("アクセスキー","シークレットキー", hostname = "s3-ap-northeast-1.amazonaws.com")
S3_get_object("bucket", "key", filename = "file")

これで、ローカルに、s3://bucket/keyが、fileで保存されます。

ポイントは、hostnameを指定してやることでした。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1