我试图使用python请求将一个文件上传到我的java/scalaspringrest服务器。我得到的答复如下:
{"timestamp":1454331913056,"status":400,"error":"Bad Request","exception":"org.springframework.web.bind.MissingServletRequestParameterException","message":"Required MultipartFile parameter 'image' is not present","path":"/parking_api/images"}
我的服务器代码:
^{pr2}$我的客户代码:
requests.post(parking_webservice_address, files={"image": ("image", open(event.pathname, "rb"), "image/jpeg")})
我试过:
files
参数设置为{"image":open(...)}
而不是元组open(...).read()
向files
参数将加载的图像数据传递到内存在服务器中设置CommonsMultipartResolver
,如下所示
@Bean(name="multipartResolver")
public CommonsMultipartResolver multipartResolver(){
return new CommonsMultipartResolver();
}
手动设置多部分头,但it服务器期望随着情况的恶化而丢失边界
这些选择对我都没用。我错过了什么?在
目前没有回答
相关问题 更多 >
编程相关推荐