add subtitle upload multer config

This commit is contained in:
OldHawk
2017-04-25 10:55:53 +08:00
parent 6eb6415667
commit cd115df1f2

View File

@@ -39,3 +39,20 @@ module.exports.createUploadFilename = function (req, file, cb) {
module.exports.getUploadDestination = function (req, file, cb) {
cb(null, config.uploads.torrent.file.dest);
};
module.exports.createUploadSubtitleFilename = function (req, file, cb) {
var regex = new RegExp(',', 'g');
var filename = file.originalname.replace(regex, ' ');
if (fs.existsSync(config.uploads.subtitles.file.dest + filename)) {
var err = new Error();
err.code = 'FILE_ALREADY_EXISTS';
cb(err, null);
} else {
cb(null, filename);
}
};
module.exports.getUploadSubtitleDestination = function (req, file, cb) {
cb(null, config.uploads.subtitles.file.dest);
};