Exemplo n.º 1
0
m.aio.syncmanager.RemoteDownloader.prototype._downloadFileFromS3=function(d,b,c){if(this._s3Client)if(b.ref){var a=require("path"),e=require("fs"),f=b.file.replace(/\//g,a.sep),g=d+a.sep+f;this._logger.log("trace","download file to:"+g);d=g.lastIndexOf(a.sep);d=g.substr(0,d);try{e.mkdirRecursiveSync(d)}catch(h){c&&c(h);return}this._s3Client.getObject({Bucket:"mediola-creator",Key:"resources/"+b.ref},function(a,b){a?c&&c(a):e.writeFile(g,b.Body,function(a){c&&c(a)})})}else c&&c(Error("file info has no ref"));
else c&&c(Error("s3 client not properly initialized"))};m.aio.syncmanager.RemoteDownloader.prototype._mkdir=function(d,b){var c=require("fs");try{c.mkdirSync(d)}catch(a){this._logger.log("warn","creator folder "+d+" error:"+a.message)}b&&b()};m.aio.syncmanager.RemoteDownloader.prototype._deldir=function(d){var b=require("fs"),c=this;b.existsSync(d)&&(b.readdirSync(d).forEach(function(a,e){a=d+"/"+a;b.lstatSync(a).isDirectory()?c._deldir(a):b.unlinkSync(a)}),b.rmdirSync(d))};
Exemplo n.º 2
0
(function(a){function g(f){var g=f.src||"";if(!g.match(d))return 0;var f=(f=f.getAttribute("data-config"))?(new Function("return "+f))():{},i=f.comboPrefix||e,k=f.comboSep||m,r,o=g.indexOf(i);-1===o?r=g.replace(b,"$1"):(r=g.substring(0,o),"/"!==r.charAt(r.length-1)&&(r+="/"),i=g.substring(o+i.length).split(k),a.each(i,function(a){if(a.match(d))return r+=a.replace(b,"$1"),!1}));"tag"in f||(i=g.lastIndexOf("?"),-1!==i&&(g=g.substring(i+1),f.tag=j.getHash(c+g)));f.base=f.base||r;return f}function f(){var a=
Exemplo n.º 3
0
m.aio.syncmanager.RemoteDownloader.prototype._downloadFileFromServer=function(d,b,c){if(b.ref){var a=require("path"),e=require("fs"),f=b.file.replace(/\//g,a.sep),g=d+a.sep+f;this._logger.log("trace","download file to:"+g);d=g.lastIndexOf(a.sep);d=g.substr(0,d);try{e.mkdirRecursiveSync(d)}catch(p){c&&c(p);return}d=require(m.aio.syncmanager.RemoteDownloader.PROTOCOL);a=this._host?this._host:m.aio.syncmanager.RemoteDownloader.OPTIONS.host;f=this._port?this._port:m.aio.syncmanager.RemoteDownloader.OPTIONS.port;
var h=m.aio.syncmanager.RemoteDownloader.OPTIONS.path+"/creatorneo/remote/downloadFile";b=b.ref.split("/");for(var k=0;k<b.length;k++)b[k]=encodeURI(b[k]);b=m.aio.syncmanager.RemoteDownloader.PROTOCOL+"://"+a+":"+f+h+"/"+b.join("/");a=this._username?encodeURIComponent(this._username):"";f=this._password?encodeURIComponent(this._password):"";b+="?username="******"&password="******"trace","download file url:"+b);var l=e.createWriteStream(g);d.get(b,function(a){a.pipe(l);l.on("finish",function(){l.close(c)})}).on("error",
function(a){e.unlink(g);c&&c(a)})}else c&&c(Error("file info has no ref"))};
Exemplo n.º 4
0
(function(a){function e(c){var e=c.src||"";if(!e.match(g))return 0;var c=(c=c.getAttribute("data-config"))?(new Function("return "+c))():{},i=c.comboPrefix||l,j=c.comboSep||m,k,u=e.indexOf(i);-1===u?k=e.replace(b,"$1"):(k=e.substring(0,u),"/"!==k.charAt(k.length-1)&&(k+="/"),i=e.substring(u+i.length).split(j),a.each(i,function(a){if(a.match(g))return k+=a.replace(b,"$1"),!1}));"tag"in c||(i=e.lastIndexOf("?t="),-1!==i&&(e=e.substring(i+1),c.tag=h.getHash(d+e)));c.base=c.base||k;return c}function k(){var a=