├── CNAME ├── README.md ├── pad-cli ├── Dockerfile ├── .github └── workflows │ └── npm-publish.yml ├── package.json ├── COPYING └── index.html /CNAME: -------------------------------------------------------------------------------- 1 | pad.js.org 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [Documentation](http://pad.js.org/) 2 | -------------------------------------------------------------------------------- /pad-cli: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('./index.html'); -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | MAINTAINER Ebrahim Byagowi "" 3 | RUN apk update && apk add nodejs 4 | ADD index.html /index.js 5 | WORKDIR /files 6 | EXPOSE 9090/tcp 7 | ENTRYPOINT node /index.js --no-cors --no-info --no-mime --timeout=-1 8 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | name: Node.js Package 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | publish-npm: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: actions/setup-node@v4 13 | with: 14 | node-version: '20' 15 | check-latest: true 16 | registry-url: https://registry.npmjs.org/ 17 | #- run: npm ci # no need to as not having any dependency 18 | - run: npm publish 19 | env: 20 | NODE_AUTH_TOKEN: ${{secrets.npm_token}} 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pad.js", 3 | "version": "0.14.3", 4 | "description": "Total fancy webserver for transfering files from/to browser console or terminal", 5 | "main": "index.html", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/ebraminio/pad.js.git" 9 | }, 10 | "keywords": [ 11 | "webserver", 12 | "cli", 13 | "commandline", 14 | "uploadserver" 15 | ], 16 | "author": "Ebrahim Byagowi", 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/ebraminio/pad.js/issues" 20 | }, 21 | "homepage": "http://pad.js.org", 22 | "scripts": { 23 | "start": "node index.html" 24 | }, 25 | "bin": { 26 | "pad.js": "pad-cli", 27 | "pad": "pad-cli" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2017 Ebrahim Byagowi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 724 | 725 | 726 | 727 | pad.js 728 |

pad.js

729 |

Total fancy node.js webserver for transferring files from/to browser console and terminal

730 | 731 | What is this? (stackoverflow) 732 | 733 |

Setup:

734 |
curl pad.js.org | node
735 | 736 |

Or:

737 |
curl pad.js.org | PORT=9090 node
738 | 739 |

Or without curl:

740 |
wget -O- pad.js.org | node
741 | 742 |

You should probably use this instead if you are using Debian/Ubuntu based Linux distribution:

743 |
curl pad.js.org | nodejs
744 | 745 |

And try this on Windows:

746 |
powershell -Command "(iwr pad.js.org).Content | node"
747 | 748 |

Or this which doesn't need curl/powershell:

749 |
node -e "require('http').request({host:'pad.js.org'},function(r){var t='';r.on('data',function(c){t+=c});r.on('end',function(){eval(t)})}).end();"
750 | 751 |

Or this sets it up as a Docker daemon which exposes pad.js on 7070 of all your interfaces:

752 |
docker run --restart=always -v /files:/files --name pad.js -d -p 7070:9090 quay.io/ebraminio/pad.js
753 | 754 |

Use this if you want to have it as a terminal tool: 755 | (please install nodejs-legacy on Debian before the installation)

756 |
npm install -g pad.js
757 | pad [PORT]
758 | 759 |

HTTPS:

760 |
761 | sudo mkdir /etc/ssl/pad.js
762 | sudo openssl genrsa -out "/etc/ssl/pad.js/pad.js.key" 2048
763 | sudo openssl req -new -key "/etc/ssl/pad.js/pad.js.key" -out "/etc/ssl/pad.js/pad.js.csr"
764 | sudo openssl x509 -req -days 365 -in "/etc/ssl/pad.js/pad.js.csr" -signkey "/etc/ssl/pad.js/pad.js.key" -out "/etc/ssl/pad.js/pad.js.crt"
765 | 
766 | Then run locally installed pad.js like: 767 |
pad --https
768 | or: (needs Node.js 8) 769 |
curl pad.js.org | node - --https
770 | or: (works only on macOS, at least for now) 771 |
curl pad.js.org | node /dev/stdin --https
772 | 773 |

Show cases:

774 | 775 | download a file from the place the server is ran from: 776 |
777 | fetch('http://127.0.0.1:9090/a.txt')
778 |   .then(x => x.text())
779 |   .then(x => console.log('File content: ' + x));
780 | 
781 | 782 | upload a text file: 783 |
784 | var formData = new FormData();
785 | formData.append('blob', new Blob(['STRING YOU LIKE TO SAVE']));
786 | fetch('http://127.0.0.1:9090/a.txt', { method: 'POST', body: formData })
787 |   .then(x => x.text())
788 |   .then(console.log);
789 | 
790 | 791 | upload a file: 792 |
793 | // Create a canvas, make 200x200 blue rectangle on it, upload its base64 encoded binary
794 | var canvas = document.createElement('canvas'), context = canvas.getContext('2d');
795 | canvas.width = 200; canvas.height = 200; context.fillStyle = 'blue'; context.fillRect(0, 0, 200, 200);
796 | canvas.toBlob(function (blob) {
797 |   var formData = new FormData();
798 |   formData.append('blob', blob);
799 |   fetch('http://127.0.0.1:9090/a.png', { method: 'POST', body: formData })
800 |     .then(x => x.text())
801 |     .then(console.log);
802 | });
803 | 
804 | 805 | upload a file from terminal: 806 |
curl -F "file=@a.png" http://127.0.0.1:9090/a.png
807 | 808 |

Source

809 | 810 |