我正在使用phonegap + rest webservice。下面给出的服务正在与 Web 应用程序测试一起工作。图像文件已上传到本地网络服务器。但是相同的服务在phonegap中不起作用。包括这里的两个代码。
休息网络服务
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("image") InputStream uploadedInputStream,
@FormDataParam("image") FormDataContentDisposition fileDetail) {
System.out.println("entered");
//some logic .. this method is working good using webapplication ... i tested using html page
}
Phonegap 代码
function myDetails()
{
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imgByte.substr(imgByte.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
var ft = new FileTransfer();
ft.upload(imgByte, IMGURL, win, fail, options);
alert("finished calling upload");
}
function win(r) {
alert("success");
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
新的一些指导
Log cat error :
04-18 18:30:31.621: E/FileTransfer(9459): {"target":"http:\/\/10.1.6.88:8080\/TodaysAdminAds\/resources\/service\/vendor\/vendorregistration","source":"\/9j\/4AAQSkZJRgABAQAAAQABAAD\/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P\/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P\/wAARCAHgA9QDASIAAhEBAxEB\/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL\/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKW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