xcode中的Cordova文件上载错误-“;WebKit丢弃了一个未捕获的异常;
我很难让文件传输在Cordova 1.6.0中工作。我没有在早期版本中尝试过,所以我不知道这是否是一个新问题xcode中的Cordova文件上载错误-“;WebKit丢弃了一个未捕获的异常;,cordova,Cordova,我很难让文件传输在Cordova 1.6.0中工作。我没有在早期版本中尝试过,所以我不知道这是否是一个新问题 var options = new FileUploadOptions(); options.fileKey = "file"; var ft = new FileTransfer(); ft.upload( imageURLToLocalFile, urlToMyServiceEndpoint, successhandler, errorhand
var options = new FileUploadOptions();
options.fileKey = "file";
var ft = new FileTransfer();
ft.upload(
imageURLToLocalFile,
urlToMyServiceEndpoint,
successhandler,
errorhandler,
options
);
在Xcode控制台中,我看到了
*** WebKit discarded an uncaught exception in the
webView:decidePolicyForNavigationAction:request:frame:decisionListener:
delegate: <NSRangeException> ***
-[JKArray objectAtIndex:]: index (1) beyond bounds (1)
而较旧的1.5.0版本是:
Cordova.exec(
successCallback,
errorCallback,
'org.apache.cordova.filetransfer',
'upload',
[options]
);
看起来上载方法已更改。我遇到了类似的问题,通过在选项后添加true解决了这个问题:
var ft = new FileTransfer();
ft.upload(
imageURLToLocalFile,
urlToMyServiceEndpoint,
successhandler,
errorhandler,
options,
**true**
);
这是Cordova 1.6.x中的一个错误,将在Cordova 1.7.0中解决(https://issues.apache.org/jira/browse/CB-543) 解决方法是手动指定所有选项(文件名、文件密钥等),因为框架错误地将它们视为必需选项 因此: 变成:
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = "image.jpg";
options.mimeType = "image/jpeg";
options.chunkedMode = true;
options.params = {}; // This line is untested as I have actual params
Rich您有没有遇到过这个错误?没有,我不得不使用另一种解决方案,结果根本没有使用FileTransfer方法,而是使用jquery ajax函数。
var options = new FileUploadOptions();
options.fileKey = "file";
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = "image.jpg";
options.mimeType = "image/jpeg";
options.chunkedMode = true;
options.params = {}; // This line is untested as I have actual params