From 5974576d28d66744d0f2cc46cf16a65ae9add2f6 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 16 Aug 2019 00:22:48 +0200 Subject: [PATCH] . --- helpers/cdn.helper.js | 10 +++++----- middlewares/uploader.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helpers/cdn.helper.js b/helpers/cdn.helper.js index b97e761..757ee9f 100644 --- a/helpers/cdn.helper.js +++ b/helpers/cdn.helper.js @@ -17,12 +17,12 @@ const CDN_PATHS = { const sanitizeFilename = (filename) => safename(sanitize(filename, { replacement: "_" })); -const getUniqueName = function (path, filename) { +const getUniqueName = function (_path, _filename) { const namer = unf({ - format: '%32b_%6r%8e', - dir: path + format: '%48b_%2i%4e', + dir: _path }); - return namer(filename) + return namer(_filename) } const getCDNMediaUrl = (mediaUri) => { @@ -53,7 +53,7 @@ const getCDNPath = (type = '') => { default: var _date = new Date(); - cdnPath = _date.getFullYear() + '/' + _date.getMonth() + '/'; + cdnPath = _date.getFullYear() + '/' + (_date.getMonth() + 1) + '/'; break; } return Path.join(config.uploads.path, cdnPath); diff --git a/middlewares/uploader.js b/middlewares/uploader.js index 9a50a34..73a3455 100644 --- a/middlewares/uploader.js +++ b/middlewares/uploader.js @@ -24,8 +24,8 @@ var cdnStorage = function(path) { }, filename: function (req, file, cb) { cdnHelper.getUniqueName(path, file.originalname) - .then(function(betterName) { - cb(null, betterName) + .then(function(betterName) { + cb(null, betterName.replace(path, '')); }); } });