本文主要包含远程桌面缓存,复制文件到远程桌面,上传文件到远程服务器,怎么传文件到远程桌面,怎么远程传输文件等相关知识,教程希望在学习及工作中可以帮助到您
");
</div>
update:更改了删除文件的方法
本文对plus.download做了简单的封装。通过common.cache.getFIle获取图片本地链接。
下载的代码块中没有指定下载的文件名及扩展名,我使用的是云服务器,获取的链接是没有文件扩展名的,故而没有做详细的限制。
本文对plus.download做了简单的封装。通过common.cache.getFIle获取图片本地链接。
下载的代码块中没有指定下载的文件名及扩展名,我使用的是云服务器,获取的链接是没有文件扩展名的,故而没有做详细的限制。
- (function(com){
- /**
- * 通过递归实现进程阻塞www.bcty365.com
- * 也可以使用async.js-->each
- * @param {Object} list
- * @param {Object} cb_exec
- * @param {Object} cb_end
- */
- function myasync(list, cb_exec, cb_end) {
- var each = function(_list, cb) {
- if (_list.length < 1) {
- return cb_end && cb_end();
- }
- cb(_list.shift(), function() {
- each(list, cb);
- })
- }
- each(list, cb_exec)
- };
- com.myasync = myasync;
- var hashCode = function(str) {
- var hash = 0;
- if (!str || str.length == 0) return hash;
- for (i = 0; i < str.length; i++) {
- char = str.charCodeAt(i);
- hash = ((hash << 5) - hash) + char;
- hash = hash & hash; // Convert to 32bit integer
- }
- return hash;
- };
- com.hashCode=hashCode;
- /**
- *存储当前下载路径
- */
- var cache = {};
- cache.getFile = function(netPath, cb) {
- var filePathCache = getLocalFileCache(netPath);
- isExist(filePathCache, function(exist) {
- if (exist) {
- console.log('EXIST_' + filePathCache)
- cb(filePathCache);
- } else {
- console.log('UNEXIST_' + filePathCache + "_" + netPath)
- Filedownload(netPath, function(localPath) {
- cb(localPath);
- });
- }
- });
- };
- /**
- * @description 检查文件是否存在
- */
- var isExist = function(localpath, cb) {
- if (!localpath) {
- return cb(false);
- }
- plus.io.resolveLocalFileSystemURL(localpath, function() {
- cb(true);
- }, function() {
- cb(false);
- });
- };
- var couDwn = 0;
- //下载
- var Filedownload = function(netPath, callback) {
- var dtask = plus.downloader.createDownload(netPath, {}, function(d, status) {
- // 下载完成&