admin管理员组文章数量:1122832
Currently in normal file upload process using java's HTTPUrlConnection, file is being uploaded via OutputStream and then call getResponse() to get server's response for uploaded file status.
But there is a big issue in error cases such as the requests need to be throttled or file is too large, or server is unavailable etc that client would upload the whole file and lost of bytes are wasted. In this case, we need client to stop the upload early, the ideal case is client to listen to server's response during uploading file.
But seems like the HTTPsUrlConnection or some libraries like OkHttp is not able to handle this, maybe due to the HTTP protocol limitations.
I have couple of options.
- Call to get response with 1xx before uploading a file - but it still will have error during upload and waste byte.
- Chunk uploads, seems like this is how Google is doing for uploading file to cloud, where each chunk can be requested separately and call the response code from server.
- Switch to other protocol, like websocket.
Wondering is there any other recommendations that I am missing? Or any feedbacks on existing options. Thanks!
本文标签: androidHTTPclient able to stop uploading file while getting server responseStack Overflow
版权声明:本文标题:android - HTTP - client able to stop uploading file while getting server response - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736307533a1933344.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论