diff --git a/index.js b/index.js index 27ccb38..f5a5f47 100644 --- a/index.js +++ b/index.js @@ -18,12 +18,10 @@ app.use(bodyParser.json()) let inDir = (dircheck,dirmain) => !path.relative(path.normalize(dircheck), dirmain).startsWith('..') - - //Get folder details -app.post('/files/cat',(req,res,next)=>{ - console.log(req.body) - const location = processing.mergedir(req.body.loc,settings) +app.get('/files/cat',(req,res,next)=>{ + //console.log(req.body) + const location = processing.mergedir(req.query.loc,settings) //const nloc = path.normalize(req.body.loc); const nloc = path.normalize(path.relative(settings.dirname,location)) if(inDir(settings.dirname,location)){ @@ -31,7 +29,6 @@ app.post('/files/cat',(req,res,next)=>{ } }) - app.post('/files/ls',(req,res,next)=>{ const location = processing.mergedir(req.body.loc,settings) //const nloc = path.normalize(req.body.loc); diff --git a/package-lock.json b/package-lock.json index 4de79f8..7274c40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -119,6 +119,14 @@ "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" }, + "busboy": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz", + "integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==", + "requires": { + "dicer": "0.3.0" + } + }, "bytes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", @@ -227,6 +235,14 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, + "connect-busboy": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/connect-busboy/-/connect-busboy-0.0.2.tgz", + "integrity": "sha1-rFyclmchcYheV2xmsr/ZXTuxEJc=", + "requires": { + "busboy": "*" + } + }, "content-disposition": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", @@ -316,6 +332,14 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "dicer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz", + "integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==", + "requires": { + "streamsearch": "0.1.2" + } + }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", @@ -1154,6 +1178,11 @@ "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, + "streamsearch": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" + }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", diff --git a/package.json b/package.json index 50d0515..9e44030 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "body-parser": "^1.19.0", "chai": "^4.2.0", "chai-http": "^4.3.0", + "connect-busboy": "0.0.2", "express": "^4.17.0", "jquery": "^3.4.1", "mocha": "^6.1.4" diff --git a/static/base.css b/static/base.css index 1d914b7..3ddcdfc 100644 --- a/static/base.css +++ b/static/base.css @@ -20,6 +20,15 @@ input[type="text"]{ border:1px gray solid; width:5rem; } + +input[type="file"]{ + display:none; +} +label[for="fileUpload"]{ + padding:0.5rem; + border:1px gray solid; +} + .window{ width:15rem; diff --git a/static/base.js b/static/base.js index 9532fb3..643fe0a 100644 --- a/static/base.js +++ b/static/base.js @@ -60,12 +60,26 @@ $(document).ready(()=>{ populateContents(); $('.file-download-button').click(()=>{ console.log(currSel) - $.ajax('/files/cat',{ + /*$.ajax('/files/cat',{ method:'post', data:currSel, xhrFields: { responseType: 'blob' }, + xhr:()=>{ + var xhr = new XMLHttpRequest(); + xhr.addEventListener('progress',(ev)=>{ + //console.log([ev.loaded,ev.total,ev.lengthComputable]) + if(ev.lengthComputable){ + $('.file-download-percent').html(`${Math.round(100*ev.loaded/ev.total)}%`) + } + + }) + xhr.upload.addEventListener('error',(ev)=>{ + $('.file-download-percent').html('F') + }) + return xhr + }, success:(msg)=>{ //console.log(msg) $('.file-download-button').after(``) @@ -73,7 +87,10 @@ $(document).ready(()=>{ $('#down-temp').remove(); }, error: err=>console.log(err) - }) + })*/ + $('.file-download-button').after(``) + document.getElementById('down-temp').click() + $('#down-temp').remove(); }) $('.close-rename').click(()=>{ $('.rename-window').fadeOut('fast') diff --git a/static/index.html b/static/index.html index e4a335f..e15c4fe 100644 --- a/static/index.html +++ b/static/index.html @@ -20,6 +20,10 @@
+