boto3 如何将 dict / json 输出上传到 s3 存储桶?
boto3 how to upload dict / json output to s3 bucket?
我无法将来自组织 describe_policy 的字典输出上传到 s3。这是我的代码
paginator = org.get_paginator('list_policies')
page_iterator = paginator.paginate(Filter='SERVICE_CONTROL_POLICY', PaginationConfig={'MaxItems': 10000})
for page in page_iterator:
for id in page['Policies']:
policyid = id['Id']
describe = org.describe_policy(PolicyId=policyid)
s3.put_object(Body=describe,Bucket='cf-asr-demo',Key=day_month_year+policyid+'/describe-scp.csv')
错误说我的输出是字典class
botocore.exceptions.ParamValidationError: Parameter validation failed:
type: <class 'dict'>, valid types: <class 'bytes'>, <class 'bytearray'>, file-like object
如何将这个基本上只是对策略的描述的输出上传到存储桶?
所以我自己修好了,我把它扔进了json
policy = json.dumps(describe)
比它奏效
我无法将来自组织 describe_policy 的字典输出上传到 s3。这是我的代码
paginator = org.get_paginator('list_policies')
page_iterator = paginator.paginate(Filter='SERVICE_CONTROL_POLICY', PaginationConfig={'MaxItems': 10000})
for page in page_iterator:
for id in page['Policies']:
policyid = id['Id']
describe = org.describe_policy(PolicyId=policyid)
s3.put_object(Body=describe,Bucket='cf-asr-demo',Key=day_month_year+policyid+'/describe-scp.csv')
错误说我的输出是字典class
botocore.exceptions.ParamValidationError: Parameter validation failed:
type: <class 'dict'>, valid types: <class 'bytes'>, <class 'bytearray'>, file-like object
如何将这个基本上只是对策略的描述的输出上传到存储桶?
所以我自己修好了,我把它扔进了json
policy = json.dumps(describe)
比它奏效