2017-06-13 64 views
0

我已經嘗試過各種嘗試來建立與S3兼容服務的連接,但我不斷收到錯誤。以下代碼將引發下面的錯誤。有任何想法嗎?Boto region_name missing

import os 
import boto 
import boto.s3.connection 
from boto.s3.key import Key 

try: 

    conn = boto.s3.connect_to_region(region = 'nil', 
    aws_access_key_id = 'xx', 
    aws_secret_access_key = 'xx', 
    host = 'ds41s3-scs.xx.com', 
    calling_format = boto.s3.connection.OrdinaryCallingFormat(), 
    ) 

    response = s3.list_buckets() 

except Exception,e: 
    print str(e) 
    print "error" 

錯誤:

TypeError: connect_to_region() missing 1 required positional argument: 'region_name' 
+0

你可能也想看看客戶設計的S3兼容的服務,如:https://github.com/ minio/minio-py –

回答

0

去爲Python最新版本的SDK AWS的(boto3),它支持最新的功能

import boto3 
client = boto3.client('s3') 

response = client.list_buckets() 
1

爲什麼region設置爲nil?的connect_to_region簽名是:

boto.s3.connect_to_region(region_name, **kw_params) 

你缺少強制參數:region_name

+0

我使用的S3服務沒有區域。我也嘗試使用region_name而不是區域,但它顯示相同的錯誤。 – user3080315