LoginSignup
2
2

More than 5 years have passed since last update.

さくらのクラウド オブジェクトストレージをPythonから操作する

Last updated at Posted at 2016-03-29

Ruby: http://qiita.com/toshitanian/items/eab866b46bdec7283d4b

さくらのクラウド オブジェクトストレージ

大容量データに対応したオブジェクトストレージサービスで、S3互換のAPIを備えています

S3とさくらオブジェクトストレージの差分

  • AWS signature version
    • S3: v4
    • さくら: v2
  • endpoint
    • S3: s3.amazonaws.com
    • さくら: b.sakurastorage.jp

PythonでS3につなぐのに使えるライブラリ

boto / boto

デファクト

boto / boto3

botoの新バージョン。こっち使ったほうがいいっぽい。

Pythonからさくらのオブジェクトストレージを操作する

python: Python 2.7.8

boto(2.32.1)

from boto.s3.connection import S3Connection

conn = S3Connection(
    'xxx', # access_key_id
    'yyyy', # secret_access_key
    host='b.sakurastorage.jp'
)
bucket = conn.get_bucket('test-bucket')
obj = bucket.get_key('sample_file.txt')
print obj.get_contents_as_string()

※クレデンシャルの管理には気をつけてね。

2
2
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
2
2