upload-client.js 396 Bytes
Newer Older
Caleb C. Sander's avatar
Caleb C. Sander committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const fs = require('fs')
const http = require('http')

const filename = process.argv[2]
const uploadName = process.argv[3]

// Make a POST request to the upload URL.
// `request` is a writable stream.
const request = http.request(
  `http://localhost/${uploadName}`,
  {method: 'POST'}
)
// Send the file to upload by piping it into the request stream
fs.createReadStream(filename).pipe(request)