.
This commit is contained in:
parent
afd69b9da4
commit
5974576d28
@ -17,12 +17,12 @@ const CDN_PATHS = {
|
|||||||
|
|
||||||
const sanitizeFilename = (filename) => safename(sanitize(filename, { replacement: "_" }));
|
const sanitizeFilename = (filename) => safename(sanitize(filename, { replacement: "_" }));
|
||||||
|
|
||||||
const getUniqueName = function (path, filename) {
|
const getUniqueName = function (_path, _filename) {
|
||||||
const namer = unf({
|
const namer = unf({
|
||||||
format: '%32b_%6r%8e',
|
format: '%48b_%2i%4e',
|
||||||
dir: path
|
dir: _path
|
||||||
});
|
});
|
||||||
return namer(filename)
|
return namer(_filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCDNMediaUrl = (mediaUri) => {
|
const getCDNMediaUrl = (mediaUri) => {
|
||||||
@ -53,7 +53,7 @@ const getCDNPath = (type = '') => {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
var _date = new Date();
|
var _date = new Date();
|
||||||
cdnPath = _date.getFullYear() + '/' + _date.getMonth() + '/';
|
cdnPath = _date.getFullYear() + '/' + (_date.getMonth() + 1) + '/';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return Path.join(config.uploads.path, cdnPath);
|
return Path.join(config.uploads.path, cdnPath);
|
||||||
|
|||||||
@ -24,8 +24,8 @@ var cdnStorage = function(path) {
|
|||||||
},
|
},
|
||||||
filename: function (req, file, cb) {
|
filename: function (req, file, cb) {
|
||||||
cdnHelper.getUniqueName(path, file.originalname)
|
cdnHelper.getUniqueName(path, file.originalname)
|
||||||
.then(function(betterName) {
|
.then(function(betterName) {
|
||||||
cb(null, betterName)
|
cb(null, betterName.replace(path, ''));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user