尝试使用Android(2.3.3)上传图片时出现BufferedInputStream错误。
示例代码
var options = new FileUploadOptions();
options.fileKey = "image";
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "https://192.168.1.128:5000/", function(resp) {
console.log(JSON.stringify(resp));
, function(e) {
console.log(JSON.stringify(e));
}, options);
异常
> java.io.IOException: BufferedInputStream is closed at
> java.io.BufferedInputStream.streamClosed(BufferedInputStream.java:116)
> at java.io.BufferedInputStream.read(BufferedInputStream.java:274)
> at
> org.apache.harmony.luni.internal.net.www.protocol.http.UnknownLengthHttpInputStream.read(UnknownLengthHttpInputStream.java:40)
> at
> org.apache.harmony.luni.internal.net.www.protocol.http.AbstractHttpInputStream.read(AbstractHttpInputStream.java:56)
> at java.io.DataInputStream.readLine(DataInputStream.java:310) at
> org.apache.cordova.FileTransfer.upload(FileTransfer.java:286) at
> org.apache.cordova.FileTransfer.execute(FileTransfer.java:85) at
> org.apache.cordova.api.PluginManager$1.run(PluginManager.java:192)
> at java.lang.Thread.run(Thread.java:1019)
经过一些搜索后,它似乎是Android 2.3.x中的一个问题(我在2.3.3上测试)。但我真的想为我的应用找到解决方案。
所以请帮助找到解决方案。