[英]Can't upload file and data in same request in Flask test
Hi i'm trying to test and endpoint that will need a file and some values, when i upload only the file there is not problem, but when i add the values it throws: 嗨,我正在尝试测试和端点,将需要一个文件和一些值,当我上传只有文件没有问题,但当我添加它抛出的值:
TypeError: 'str' does not support the buffer interface
my code is like this: 我的代码是这样的:
headers = {'content-Type': 'multipart/form-data'}
response = self.client.post(base_url, headers=headers, data=dict(
some_value='test', some_other_value=False, image=(BytesIO(self.test_image), 'image.png'))
if i do this it works: 如果我这样做它有效:
headers = {'content-Type': 'multipart/form-data'}
response = self.client.post(base_url, headers=headers, data=dict(
image=(BytesIO(self.test_image), 'image.png'))
不知道它与什么有什么关系,但是当我从一个值中的False变为'false'时它起作用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.