https://github.com/imightexist/node-hfs
a nodejs hfs server
https://github.com/imightexist/node-hfs
Last synced: 2 months ago
JSON representation
a nodejs hfs server
- Host: GitHub
- URL: https://github.com/imightexist/node-hfs
- Owner: imightexist
- Created: 2022-05-02T01:41:50.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-05T22:56:02.000Z (almost 3 years ago)
- Last Synced: 2025-01-05T00:44:00.742Z (4 months ago)
- Language: HTML
- Size: 59.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-HFS
a nodejs hfs server
## npm packages to install
Type this in the terminal before running: `npm install express path ws mime`
## Warning
if you need to, change the password in .env instead of config.json and change the code as well.
## downloading with websocket
We have added direct downloads. you're welcome, but you can still download with websocket.
```javascript
const websocketClient = require('websocket').client;
const ws = new websocketClient();
const fs = require('fs')
ws.on('connection',function(f){
f.sendUTF(JSON.stringify(['readfile','test.txt']));
f.on('message',function(msg){
message = JSON.parse(msg);
if (message[0] == "download"){
//message 1 is a data url
//message 2 is the filename
var regex = /^data:.+\/(.+);base64,(.*)$/;var matches = message[1].match(regex);
var ext = matches[1];
var data = matches[2];
var buffer = Buffer.from(data, 'base64');
fs.writeFileSync(message[2], buffer);
}
}
}
ws.connect("wss://hfs.astroistaken.repl.co");
```
## Demo
https://hfs.astroistaken.repl.coYou can only upload 1 mb files