1

尝试使用 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 上进行测试)。但我真的很想为我的应用程序找到解决方案。

因此,请帮助找到解决方案。

4

0 回答 0