我在node.js中有一个图片上传网络服务,它运行良好,我可以通过邮递员上传图片,我尝试在android上拍照比上传它,node.js总是回复
'未定义'
没有错误消息,只有服务器显示未定义
我使用与邮递员相同的代码给我,但不能工作,请帮忙,坚持上传两天
我的代码
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=-- -011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"images\"; filename=\"Costa Rican Frog.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n\r\n-----011000010111000001101001--");
Request request = new Request.Builder()
.url("http://localhost:3000/upload")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "e360f8ea-d179-fc78-6dff-c56791b7d9ba")
.build();
Response response = client.newCall(request).execute();
邮递员代码
class Foo {
public Foo(int x, int y) {}
}