https://github.com/kathan/send-it
https://github.com/kathan/send-it
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kathan/send-it
- Owner: kathan
- Created: 2018-03-09T17:11:38.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-09T17:27:47.000Z (over 8 years ago)
- Last Synced: 2025-11-17T16:27:29.277Z (8 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# send-it
A Javascript module that simplifies sending files and data over HTTP.
## Usage:
Create a server...
```js
const path = require('path');
const bodyParser = require('body-parser');
const express = require('express');
const fileUpload = require('express-fileupload');
const app = express();
const port = 8080;
//==== Start Server ====
app.use(bodyParser.urlencoded({ extended: true }));
app.use(fileUpload());
app.post('*', (req, res) => {
console.log({file_name: req.files.file.name});
res.send('Success!');
});
var server = app.listen(port, () => {
console.log(`Test app listening on port ${port}!`);
});
```
...then send a file!
```js
const sendIt = require('send-it');
const port = 8080;
//==== Send File ====
sendIt(`http://localhost:${port}`, path.resolve(__dirname, 'test.file'), (err, result, reply)=>{
if(result){
console.log('Success!');
}else{
console.log('Error!', reply.statusCode);
}
});
```