python - 发送带有枕头图像的 POST 请求
问题描述
我从 pymongo 得到这样的图像:
def get_my_photo(self, user_id):
res = self.db.find_one({'user_id': user_id})
image_data = BytesIO(res['photo'])
image = Image.open(image_data)
image_data = BytesIO()
image.save(image_data, "JPEG")
image_data.seek(0)
return image_data
然后我尝试使用 image_data 发送 POST 请求:
request = requests.post(url, files={'photo': image})
但标题是:
'Content-Type': 'text/html; charset=windows-1251'
. 并且没有照片上传。如何正确发送带有请求的 Pillow 图像?谢谢。
编辑:在这篇文章中找到解决方案
解决方案
推荐阅读
- steam-web-api - Steam Web API 未检索用户评论
- ruby-on-rails - 如何使用carrierwave获取S3私有存储桶中对象的访问url
- google-cloud-composer - Cloud Composer 缺少变量文件
- ionic-framework - 图表未显示数据
- html - 悬停和大型菜单在导航项中不起作用
- azure - Microsoft.Azure.Management.EventHub.Models 中的目标类没有支持 Data Lake Storage 的属性
- wordpress - 分页不起作用,我考虑修复或新编码
- ssh - SSH 进入服务器,稍后使用 Phing 执行 sudo
- java - getSelectionModel().getSelectedItem(); 对象无法转换为 Lekarz- Gui FX
- list - 遍历多个字典中的多个列表