From 95fb0075c661b3ea9a67c7763a58655e4b178212 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 4 Feb 2016 10:13:03 -0500 Subject: [PATCH] re-added missing base64ToLocal method in file lib --- src/file.js | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) {