Python 3.x 请求太大向应用程序引擎发出请求时出错
我在AppEngineFlex上有一个使用Python3运行时的应用程序。我使用下面的代码从Google存储中获取简历文件的base64编码字节字符串Python 3.x 请求太大向应用程序引擎发出请求时出错,python-3.x,google-app-engine,python-requests,Python 3.x,Google App Engine,Python Requests,我在AppEngineFlex上有一个使用Python3运行时的应用程序。我使用下面的代码从Google存储中获取简历文件的base64编码字节字符串 storage_client = storage.Client(project=[MYPROJECT]) bucket = storage_client.get_bucket([MYBUCKET]) blob = bucket.blob([MYKEY]) resume_file = blob.download_as_string() resum
storage_client = storage.Client(project=[MYPROJECT])
bucket = storage_client.get_bucket([MYBUCKET])
blob = bucket.blob([MYKEY])
resume_file = blob.download_as_string()
resume_file = str(base64.b64encode(resume_file))[2:-1]
我将其作为请求参数的一部分发送,如下所示:
headers = {'Authorization': 'Bearer {}'.format(signed_jwt),
'content-type': 'application/json'}
params = {'inputtype': 'file',
'resume': resume_file}
response = requests.get(HOST, headers=headers, params=params)
但是,我得到以下错误:
错误413(请求实体太大)
您的客户发出的请求太大
我们只知道这些
应用程序引擎的文件大小限制为32MB。然而,我的文件只有24KB。如何修复此错误?我必须将应用程序更改为接受POST请求而不是GET请求 以前,我把简历作为参数发送。我现在将其作为数据发送:
payload = json.dumps({
'inputtype': inputtype,
'resume': inputresume
})
response = requests.post(HOST, headers=headers, data=payload)
我用的是烧瓶。之前,我使用以下方法阅读参数:
request.args.get('resume')
我把它改成:
request.get_json().get('resume')
这是问题/答案的扩展你能显示代码吗?我已经编辑了原始帖子@DanCornilescu