我使用http://posttestserver.com/post.php 来测试我的Android设备上使用改装的多部分文件上传。我得到了成功回应:
Time: Wed, 16 Mar 16 23:14:04 -0700
Source ip:
Headers (Some may be inserted by server)
REQUEST_URI = /post.php
QUERY_STRING =
REQUEST_METHOD = POST
GATEWAY_INTERFACE = CGI/1.1
REMOTE_PORT = 57241
REMOTE_ADDR = 117.217.235.52
HTTP_USER_AGENT = okhttp/3.0.1
HTTP_ACCEPT_ENCODING = gzip
HTTP_CONNECTION = close
HTTP_HOST = posttestserver.com
CONTENT_LENGTH = 610
CONTENT_TYPE = multipart/form-data; boundary=b9c564cd-fcab-48fc-b034- 75ee43c0db90
UNIQUE_ID = VupLLEBaMGUAAHKlJhoAAAAT
REQUEST_TIME_FLOAT = 1458195244.3543
REQUEST_TIME = 1458195244
Post Params:
key: 'description' value: 'hello, this is description speaking'
Empty post body.
== Multipart File upload. ==
Received 1 file(s)
0: posted name=upload
name: 1
type: application/json
error: 0
size: 122
Uploaded File: http://posttestserver.com/files/2016/03/16/f_23.14.04276262399
上面的最后一行显示了上传的文件。但打开此链接会显示上传文件的元数据。
{"headers":{"namesAndValues":["Content-Disposition","form-data; name=\"picture\"; filename=\"IMG-20160316-WA0004.jpg\""]}}
我在哪里可以找到实际上传的图片?
答案 0 :(得分:0)
尝试使用ION类工作正常。单击上述链接时不显示图像。
分享以下代码。
Ion.with(context)
.load("http://posttestserver.com/post.php").setLogging("MyLogs", Log.VERBOSE)
.uploadProgressBar(h.progress)
.setMultipartFile("archive", "image/*", new File(source.getPath()))
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String result) {
if (e != null) {
Log.e("Error Result", e.toString());
}
Log.d("Result", result);
}
});