Skip to content

Instantly share code, notes, and snippets.

@aqkhan
Created July 25, 2022 09:38
Show Gist options
  • Save aqkhan/b6d2c8b384373a49630ac13f12030ed8 to your computer and use it in GitHub Desktop.
Save aqkhan/b6d2c8b384373a49630ac13f12030ed8 to your computer and use it in GitHub Desktop.
Nodejs file upload
app.post('/google-bulk-create', async (req, res) => {
try {
// No file uploaded
if(!req.files) {
res.send({
status: false,
message: 'No file uploaded'
});
}
// File uploaded
else {
let csvFile = req.files.csvFile;
// Parse CSV file below
//send response
res.status(200).json({
status: true,
message: 'File is uploaded',
data: {
name: csvFile.name,
mimetype: csvFile.mimetype,
size: csvFile.size
}
});
}
} catch (err) {
res.status(500).send(err);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment