如何解决cordova上传错误

时间:2014-09-26 04:54:10

标签: file cordova upload

09-26 12:52:27.585: D/FileTransfer(3661): chunkedMode: true
09-26 12:52:27.585: D/FileTransfer(3661): headers: null
09-26 12:52:27.585: D/FileTransfer(3661): objectId: 2
09-26 12:52:27.585: D/FileTransfer(3661): httpMethod: POST
09-26 12:52:27.585: E/PluginManager(3661): Uncaught exception from plugin


09-26 12:52:27.585: E/PluginManager(3661): java.lang.IllegalArgumentException: **Relative URIs are not** supported.
09-26 12:52:27.585: E/PluginManager(3661):  at org.apache.cordova.CordovaResourceApi.assertNonRelative(CordovaResourceApi.java:428)
09-26 12:52:27.585: E/PluginManager(3661):  at org.apache.cordova.CordovaResourceApi.remapUri(CordovaResourceApi.java:138)
09-26 12:52:27.585: E/PluginManager(3661):  at org.apache.cordova.filetransfer.FileTransfer.upload(FileTransfer.java:256)
09-26 12:52:27.585: E/PluginManager(3661):  at org.apache.cordova.filetransfer.FileTransfer.execute(FileTransfer.java:182)
09-26 12:52:27.585: E/PluginManager(3661):  at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:84)
09-26 12:52:27.585: E/PluginManager(3661):  at org.apache.cordova.PluginManager.exec(PluginManager.java:147)
09-26 12:52:27.585: E/PluginManager(3661):  at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
09-26 12:52:27.585: E/PluginManager(3661):  at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:40)
09-26 12:52:27.585: E/PluginManager(3661):  at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
09-26 12:52:27.585: E/PluginManager(3661):  at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
09-26 12:52:27.585: E/PluginManager(3661):  at android.os.Handler.dispatchMessage(Handler.java:102)
09-26 12:52:27.585: E/PluginManager(3661):  at android.os.Looper.loop(Looper.java:157)
09-26 12:52:27.585: E/PluginManager(3661):  at android.os.HandlerThread.run(HandlerThread.java:61)

1 个答案:

答案 0 :(得分:0)

对我而言,这个问题源于这一行

org.apache.cordova.filetransfer.FileTransfer.upload(FileTransfer.java:256)

final Uri targetUri = resourceApi.remapUri(Uri.parse(target));

确保您的后端正在发送包括主机在内的完整目标路径。