Skip to content

Commit

Permalink
Merge pull request #19 from J-P-S-O/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
Octalbyte authored Dec 6, 2021
2 parents 5d953c9 + 5f00980 commit ea18233
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 4 additions & 3 deletions run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions static/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ 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);

}
}

reader.readAsBinaryString(file);
//reader.readAsBinaryString(file);
reader.readAsArrayBuffer(file);



Expand Down

0 comments on commit ea18233

Please sign in to comment.