我有一个简单的应用程序混合动力应该与下载2.3.0科尔多瓦文件。从文档:
I have a simple hybrid app which should download files with cordova 2.3.0. From the documentation:
var filePath = someFullPath; //e.g. "file:///mnt/sdcard/myfile.pdf" var uri = encodeURI("someurl/myfile.pdf"); var fileTransfer = new FileTransfer(); fileTransfer.download( uri, filePath, function(entry) { console.error("download complete: " + entry.fullPath); }, function(error) { console.error("download error source " + error.source); console.error("download error target " + error.target); console.error("donwload error code " + error.code); console.error("http: "+error.http_status); } ); }的结果是错误3,Connection_Err,与HTTP_STATUS 401,资源myfile.pdf是公开的,没有身份验证需要一个HTTP服务器上。
The outcome is error 3, Connection_Err, with http_status 401, the resource myfile.pdf is public on a http server with no auth required.
我曾经尝试都创建该文件的文件://mnt/sdcard/myfile.pdf用的GetFile(我的file.pdf,{创建:真实,独家:假},成功,失败);或者只是设置一个字符串现有的目录。它并没有在这两种情况下工作。
I have tried both creating the file file://mnt/sdcard/myfile.pdf with getFile("my file.pdf", {create: true, exclusive: false}, success, fail); or just setting a string to an existing directory. It didn't work in both scenarios.
能否请您指教?我必须用科尔多瓦2.3.0。
Can you please advise? I have to use cordova 2.3.0.
更新:
我想我的问题是非常接近此一:文件传输中的PhoneGap code 401
I think my problem is very close to this one: FileTransfer in Phonegap code 401
我的Android API 17,科尔多瓦2.3.0,我需要设置允许原点=*,但我不能创建config.xml文件,因为某些原因,它抛出的错误。你有没有遇到这个问题?
I have Android API 17, cordova 2.3.0, I need to set allow origin = "*", but I can't create the config.xml file, for some reasons it throws errors. Have you faced this problem?
我创建资源里面的文件夹XML(有没有一)和创建这样的文件夹中的文件config.xml中。 config.xml文件的内容是
I created the folder xml inside res (there wasn't one) and created a file config.xml inside such folder. The content of the config.xml is
<access origin="*"></access>当我运行应用程序,我得到这个错误警报:错误初始化科尔多瓦:找不到类
when I run the application I get an alert with this error: Error Initializing Cordova: Class not found
推荐答案所有code是正确的,这是我的框架结构的问题:
All the code was correct, it was a problem with my configuration of the framework:
该项目还有另外一个项目作为库的依赖。这个项目没有一个config.xml文件,其中列入白名单的URL。库项目了!我只需要添加
this project had another project as library dependence. This project didn't have a config.xml file where to whitelist URLs. The library project had! I just needed to add the
<access origin="*.somedomain"></access>要正确的config.xml文件科尔多瓦,这是在一个库项目,而不是在主要项目本身。
to the "right" config.xml cordova file, which was in a Library project, not in the main project itself.
更多推荐
科尔多瓦文件传输下载错误
发布评论