diff --git a/README.md b/README.md index 9be2991..6b59acc 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,20 @@ # 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 :). -## Bugs -The only current issue with the server is that binary files of all sorts (.png, .jpg, .docx, .pptx) get corrupted. This is under investigation. + ## How to use ``` -git clone https://github.com/J-P-S-O/quickload --branch v1.0.0 +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) 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);