[英]Abort file upload by post
I use org.apache.http.client.HttpClient 我使用org.apache.http.client.HttpClient
to upload large files from Android to server. 将大型文件从Android上传到服务器。
(...)
entity.addPart(...)
entity.addPart("mediafile", new FileBody(file));
httpost.setEntity(entity);
HttpResponse response = httpClient.execute(httpost);
(...)
The files are large and I need a method to cancell upload if user request, but HttpClient don´t have function to abort network operation. 文件很大,如果用户请求,我需要一种方法来取消上传,但是HttpClient没有中止网络操作的功能。
How I can terminate this network operation? 如何终止此网络操作?
but HttpClient don´t have function to abort network operation. 但是HttpClient没有终止网络操作的功能。
You can use httpost.abort();
您可以使用httpost.abort();
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.