对contentync phonegap插件(https://www.npmjs.com/package/phonegap-plugin-contentsync)有疑问 如果有人能提供帮助,我们将非常感激。 问题的核心是我的REST服务器允许我下载.epub文件(与.zip相同)只能通过发送类似于的GET请求来下载:
https://test-api.books.com/api/getPublishedEpub?session_hash=1235&publication_id=abv1243'
为插件提供此链接' .sync'我打电话给我一个无效的请求方法'来自服务器的响应...
在尝试下载普通的.zip时,一切正常。
var pub_id = $scope.currentBook.publication_id, epubUrl = 'https://test-api.books.com/api/getEpub?session_hash='
+ $rootScope.sessionHash+ '&publication_id=' + pub_id;
var downloadBtn = document.getElementById("downloadBtn");
console.log('Download cliked');
var sync = ContentSync.sync({ src: epubUrl, id: 'book'+ pub_id});
sync.on('progress', function (data) {
downloadBtn.innerHTML = "Downloading: " + data.progress + "%";
});
sync.on('complete', function (data) {
console.log(data.localPath);
for (var x = 1; x <= 17; x++) {
var fileUrl = "file://" + data.localPath;
console.log(fileUrl);
}
downloadBtn.innerHTML = 'Download';
});