This commit is contained in:
+9
-2
@@ -163,8 +163,15 @@ module.exports.getFile = function(root) {
|
||||
if(fs.existsSync(root)) {
|
||||
|
||||
try {
|
||||
|
||||
return fs.readFileSync(root, "utf-8")
|
||||
|
||||
// Check if the file is an image and if it is return the base64
|
||||
if(mime.lookup(root).includes("image")) {
|
||||
return "data:" + mime.lookup(root) + ";base64," + fs.readFileSync(root, "base64")
|
||||
} else {
|
||||
return fs.readFileSync(root, "utf-8")
|
||||
}
|
||||
|
||||
|
||||
} catch(err) {
|
||||
console.log(err)
|
||||
return "NOT_PERMITTED"
|
||||
|
||||
Reference in New Issue
Block a user