simple file upload as a service with nodejs.
fu is a simple file upload api server built with express and express-fileupload.
This is nothing more than an experiment, in a multitude of experiments that'd follow, if I do my #100DaysOfCode challenge seriously :)
# With NPM
npm install
npm start
# With Yarn
yarn
yarn start
- To upload a file hit the endpoint
/file
with a POST request of the formpayload=filename.ext
.
# example with curl
$ curl -F '[email protected]' -i http://localhost:3030/file
HTTP/1.1 200 OK
X-Powered-By: Express
Location: /file/file_DIBjE8qishKn.png
Content-Type: text/html; charset=utf-8
Content-Length: 7
ETag: W/"7-U6VofLJtxB8qtAM+l+E63v03QNY"
Date: Sun, 10 Jun 2018 18:14:15 GMT
Connection: keep-alive
- We'll get the location in the response header as
Location: /file/newFileName.ext
. - To get the file back, do a GET request to
/file
of the form/file/newFileName.ext
Note: Take a look at config.js to see the defaults.
- Make a better README
- Write better code dummy! Write vanilla JS, so as to remove deps
Set file size limits- Make an init script
- Make it more thumbor - like.
- Use this as an excuse to do a docker tutorial.
package.json
has astart:cors
field.- File size limit. Check config.js