Created
December 19, 2021 15:36
-
-
Save sidharrth2002/5b09ce1b3bd1af670a27568a74fb8e7d to your computer and use it in GitHub Desktop.
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
let randomFileName = uuidv4() + '.' + req.file.originalname.split('.')[req.file.originalname.split('.').length - 1]; | |
let filename = req.file.originalname; | |
sharp(req.file.buffer) | |
.jpeg({ | |
quality: 30, | |
}) | |
.withMetadata() | |
.rotate() | |
.toBuffer() | |
.then((data) => { | |
minioClient.putObject('reports', randomFileName, data, function(err, etag) { | |
if(err) { | |
res.status(500).send({ | |
message: err, | |
status: 'failed to upload to minio' | |
}) | |
} else { | |
res.status(200).send({ | |
message: etag, | |
status: `${randomFileName} uploaded successfully`, | |
secure_url: minioClient.protocol + '//' + minioClient.host + ':' + minioClient.port + '/reports/' + randomFileName | |
}) | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment