From e81f6d3f1ffac064bc1585fb5d4b4744e5f09dc3 Mon Sep 17 00:00:00 2001 From: jp Date: Mon, 6 Dec 2021 15:10:04 -0300 Subject: [PATCH 1/2] . --- run.js | 7 ++++--- static/start.js | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/run.js b/run.js index 6e80ec2..186d774 100644 --- a/run.js +++ b/run.js @@ -5,7 +5,7 @@ With love, - @J-P-S-O (Octopus) */ - +console.clear() let mime = require('mime-types') let prompt = require("prompt-sync")() let fs = require("fs") @@ -89,13 +89,14 @@ const requestListener = function (req, res) { }else if(String(req.url).split("?")[0]==="/upload"){ console.log("[UPLOAD STARTED]") //console.log("upload") - let body = ""; + let body = []; req.on("data",(chunk)=>{ //console.log(String(chunk)) - body += chunk + body.push(chunk) }) req.on("end",()=>{ + body = Buffer.concat(body) res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Success: your code is "+ intcode); //console.log(req.headers) diff --git a/static/start.js b/static/start.js index 4974395..ecde3fa 100644 --- a/static/start.js +++ b/static/start.js @@ -14,12 +14,12 @@ upbutton.onchange = function(e){ reader.onload = function(e) { console.log(reader.result) + console.log(new Blob([reader.result]).size) console.log(file.type) console.log(file.name) let xhr = new XMLHttpRequest() xhr.open('POST', '/upload') xhr.setRequestHeader('Content-Type', file.type); - xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.send(reader.result) xhr.onload = () => { window.alert(xhr.responseText); @@ -27,7 +27,8 @@ upbutton.onchange = function(e){ } } - reader.readAsBinaryString(file); + //reader.readAsBinaryString(file); + reader.readAsArrayBuffer(file); From 51604a4c35b1dbba8053ca3e1148a7923047e9fd Mon Sep 17 00:00:00 2001 From: jp Date: Mon, 6 Dec 2021 15:12:29 -0300 Subject: [PATCH 2/2] Update Readme --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 37e94c5..e77905e 100644 --- a/README.md +++ b/README.md @@ -1 +1,17 @@ -# quickload \ No newline at end of file +# quickload +Quickload is a fast NodeJS app intended for the sharing of files between different computers in a fast manner. This way you can stop sending emails to yourself :). +## How to use +``` +git clone https://github.com/J-P-S-O/quickload --branch v1.0.1 +cd quickload +npm i +node run.js +``` + +After this, access https://localhost:80 (You can use ngrok to generate public URLs). +1. Click "Upload File" and select a file +2. Save (or remember) the code alerted in the browser window +3. Download the file on another machine by inserting the code in the text box and clicking "Download" + +## Example command line log +![image](https://user-images.githubusercontent.com/66487668/144876706-8caecd00-d241-4482-ac1b-05153698b485.png) \ No newline at end of file