Google Cloud Platformに未処理のJSONデータをアップロードしようとしています。しかし、私はこのエラーを取得しています:Pythonコードを使用してGoogle Cloud Storageに未処理のJSONデータをアップロード
TypeError: must be string or buffer, not dict
コード:
def upload_data(destination_path):
credentials = GoogleCredentials.get_application_default()
service = discovery.build('storage', 'v1', credentials=credentials)
content = {'name': 'test'}
media = http.MediaIoBaseUpload(StringIO(content), mimetype='plain/text')
req = service.objects().insert(
bucket=settings.GOOGLE_CLOUD_STORAGE_BUCKET,
body={"cacheControl": "public,max-age=31536000"},
media_body=media,
predefinedAcl='publicRead',
name=destination_path,
)
resp = req.execute()
return resp
コードStringIO(content)
を変更することにより、勤務をStringIO(json.dumps(content))
お願いします。 – Naveen