Mongodb Tutorial To Store Unstructured Data
Mongodb Tutorial To Store Unstructured Data
-> Start the client and create uploadDB database and collection in it 'files'
--> index.html
<html>
<head>
<title>Upload files</title>
</head>
<body>
</form>
</body>
</html>
const fs = require('fs')
})
getFiles(res)
})
app.use(fileUpload())
insertFile(file, res)
})
if (err) {
return err
else {
try {
collection.insertOne(file)
console.log('File Inserted')
catch (err) {
client.close()
res.redirect('/')
})
}
function getFiles(res) {
if (err) {
return err
else {
if (err) {
else {
fs.writeFileSync('uploadedImage.jpg', buffer)
})
client.close()
res.redirect('/')
})
}
app.use("/", router)
-----------------------------------------------------------------------------------------------------------------
nodemon index.js
upload file