2017-08-01 3 views
0

私はPythonとSimpleDBとのやり取りにAWS SDKを使用しています。SimpleDBでのbatch_put_attributesのエンコーディング

client = boto3.client('sdb') 

example = [ 
    {'Name': 'test1', 'Attributes': [ 
     {'Name': 'speaker', 'Value': 'DIEGO BASSANTE'}]}, 
    {'Name': 'test2', 'Attributes': [ 
     {'Name': 'speaker', 'Value': 'SERGIO JOSE'}]}] 

response = client.batch_put_attributes(
    DomainName='activities', 
    Items=example 
) 

このコードは動作しますが、Valueは U、私はエラーを取得、O、I、E、A、ñなどの特殊文字を持っている場合:店へ

botocore.exceptions.ClientError: An error occurred (SignatureDoesNotMatch) when calling the BatchPutAttributes operation: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.

SDBのsuposesをUTF-8としてのデータと、batch_delete_attributesの方法で文書化されている属性にフィールドAlternateValueEncodingを追加しようとしましたが、まだ運がありません。

SDBにデータを送信するときにbase64にデータをエンコードし、データを返すときにデコードすることについて考えましたが、それが正しい答えであるかどうかはわかりません。それで私は何が欠けているのですか?

パイソン:3.6.2 boto3:それは報告された問題であるような1.4.5

答えて

0

は思える https://github.com/boto/boto3/issues/354

問題がsdbに送信された要求ヘッダの値charset=utf-8を必要とすることであるContent-Type

私のコードでこのスニペットをコピーするだけで、提案された解決策が私のために働いた

from botocore import endpoint 


def make_request(self, operation_model, request_dict): 
    if self._endpoint_prefix == 'sdb': 
     request_dict['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8' 
    return self._send_request(request_dict, operation_model) 
endpoint.Endpoint.make_request = make_request