Created
July 25, 2022 09:38
-
-
Save aqkhan/b6d2c8b384373a49630ac13f12030ed8 to your computer and use it in GitHub Desktop.
Nodejs file upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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