【发布时间】:2013-12-14 21:12:32
【问题描述】:
我的移动应用程序有两个目标。
a) 用手机的相机拍照并上传到服务器
b) 从手机图库中挑选图片并上传到服务器
我一直在使用Phonegap,点“a”效果很好。也是“b”。
问题:似乎每秒钟上传一次都会失败。无论我是从“a”点还是“b”点开始。或者随机组合。
结果:
1. 成功
2. 失败
3. 成功
4. 失败
4.等
这是我的点“a”的代码:
function getImageCamera() {
navigator.camera.getPicture(uploadPhotoCamera, function(message) {
},{
targetWidth: 1200,
targetHeight: 900,
quality: 75,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.CAMERA
}
);
}
对于点“b”:
function getImageGallery() {
navigator.camera.getPicture(uploadPhotoGallery, function(message) {
},{
targetWidth: 1200,
targetHeight: 900,
quality: 75,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.SAVEDPHOTOALBUM
}
);
}
uploadPhotoCamera 和uploadPhotoGallery 的功能是一样的。
这里是 Eclipse 日志:
12-14 22:44:15.303: W/FileTransfer(32613): Error getting HTTP status code from connection.
12-14 22:44:15.303: W/FileTransfer(32613): java.io.EOFException
12-14 22:44:15.303: W/FileTransfer(32613): at libcore.io.Streams.readAsciiLine(Streams.java:203)
12-14 22:44:15.303: W/FileTransfer(32613): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
12-14 22:44:15.303: W/FileTransfer(32613): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
12-14 22:44:15.303: W/FileTransfer(32613): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
12-14 22:44:15.303: W/FileTransfer(32613): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
12-14 22:44:15.303: W/FileTransfer(32613): at org.apache.cordova.FileTransfer$1.run(FileTransfer.java:484)
12-14 22:44:15.303: W/FileTransfer(32613): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-14 22:44:15.303: W/FileTransfer(32613): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-14 22:44:15.303: W/FileTransfer(32613): at java.lang.Thread.run(Thread.java:856)
12-14 22:44:15.311: E/FileTransfer(32613): {"target":"http:\/\/some_IP\/api_upload.php","source":"file:\/\/\/storage\/emulated\/0\/Android\/data\/com.tisamobile\/cache\/resize.jpg?1387057455160","http_status":0,"code":3}
12-14 22:44:15.311: E/FileTransfer(32613): java.io.EOFException
12-14 22:44:15.311: E/FileTransfer(32613): at libcore.io.Streams.readAsciiLine(Streams.java:203)
12-14 22:44:15.311: E/FileTransfer(32613): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
12-14 22:44:15.311: E/FileTransfer(32613): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
12-14 22:44:15.311: E/FileTransfer(32613): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
12-14 22:44:15.311: E/FileTransfer(32613): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
12-14 22:44:15.311: E/FileTransfer(32613): at org.apache.cordova.FileTransfer$1.run(FileTransfer.java:484)
12-14 22:44:15.311: E/FileTransfer(32613): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-14 22:44:15.311: E/FileTransfer(32613): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-14 22:44:15.311: E/FileTransfer(32613): at java.lang.Thread.run(Thread.java:856)
12-14 22:44:15.311: E/FileTransfer(32613): Failed after uploading 103425 of 103425 bytes.
可能出了什么问题?任何建议表示赞赏。
【问题讨论】:
-
此问题已解决:stackoverflow.com/questions/17851259/… rand_mem_RAM 于 9 月 7 日 5:07 回答。
标签: javascript android mobile cordova