到 Google Storage 申請帳號,過兩天收到認證信,開通以後填入信用卡帳號,就可以開始使用了,
先到 key management 申請一個 key ,然後抓 http://code.google.com/p/gsutil/ API 的函式庫,
然後用 Python 2.5 ~2.7 執行 gsutil ls 他就會幫你產生 .boto 設定檔 填入 剛申請的 key 跟 secret,就可以按照範例執行程式了。
#!/usr/bin/python import StringIO import os import shutil import tempfile import time import boto # Read developer keys from the ~/.boto config file. config = boto.config # URI scheme for Google Storage. GOOGLE_STORAGE = 'gs' # URI scheme for accessing local files. LOCAL_FILE = 'file' now = time.time() CATS_BUCKET = 'cats-%d' % now DOGS_BUCKET = 'dogs-%d' % now for name in (CATS_BUCKET, DOGS_BUCKET): # Instantiate a BucketStorageUri object. uri = boto.storage_uri(name, GOOGLE_STORAGE) # Try to create the bucket. try: uri.create_bucket() print 'Successfully created bucket "%s"' % name except boto.exception.StorageCreateError, e: print 'Failed to create bucket:', e