Created
December 19, 2022 16:43
-
-
Save samuelkarani/ea5a4b83045f23310f688a4e854149e7 to your computer and use it in GitHub Desktop.
This file contains 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
const fs = require('fs'); | |
const crypto = require("crypto"); | |
app.post('/upload', async (req, res) => { | |
const randomId = crypto.randomBytes(16).toString("hex"); | |
const filePath = __dirname + "/uploads/" + randomId; | |
const writeStream = fs.createWriteStream(filePath); | |
writeStream.on('finish', () => { | |
const { is_infected, viruses } = await scanFile(filePath); | |
if (!is_infected) { | |
// upload to AWS S3 | |
} | |
}) | |
request.pipe(writeStream); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment