Skip to content

Node.js based forum software built for the modern web

re-added missing base64ToLocal method in file lib

Julian Lam95fb0075c661
diff --git a/src/file.js b/src/file.js
index 151a66f992..1c1cab7781 100644
--- a/src/file.js
+++ b/src/file.js
@@ -38,6 +38,17 @@ file.saveFileToLocal = function(filename, folder, tempPath, callback) {
is.pipe(os);
};
+file.base64ToLocal = function(imageData, uploadPath, callback) {
+ var buffer = new Buffer(imageData.slice(imageData.indexOf('base64') + 7), 'base64');
+ uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), uploadPath);
+
+ fs.writeFile(uploadPath, buffer, {
+ encoding: 'base64'
+ }, function(err) {
+ callback(err, uploadPath);
+ });
+};
+
file.isFileTypeAllowed = function(path, callback) {
// Attempt to read the file, if it passes, file type is allowed
jimp.read(path, function(err) {