Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import express from 'express';
import axios from 'axios';
import multer from 'multer';
const app = express();
... express.js boilerplate
routes, middlewares, helpers, loggers, etc
// configuring Multer to use files directory for storing files
// this is important because later we'll need to access file path
const storage = multer.diskStorage({
destination: './files',
filename(req, file, cb) {
cb(null, `${new Date()}-${file.originalname}`);
const upload = multer({ storage });
// express route where we receive files from the client
// passing multer middleware'/files', upload.single('file'), (req, res) => {
const file = req.file; // file passed from client
const meta = req.body; // all other values passed from the client, like name, etc..
// send the data to our REST API
url: ``,
method: 'post',
data: {
.then(response => res.status(200).json(
.catch((error) => res.status(500).json(;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment