Add extensions for cropped images

This commit is contained in:
pichalite
2017-02-17 19:42:02 +00:00
parent a379b03e71
commit 8dab8864f6
3 changed files with 87 additions and 42 deletions

View File

@@ -6,6 +6,7 @@ var path = require('path');
var winston = require('winston');
var jimp = require('jimp');
var mkdirp = require('mkdirp');
var mime = require('mime');
var utils = require('../public/src/utils');
@@ -13,8 +14,8 @@ var file = {};
file.saveFileToLocal = function (filename, folder, tempPath, callback) {
/*
* remarkable doesn't allow spaces in hyperlinks, once that's fixed, remove this.
*/
* remarkable doesn't allow spaces in hyperlinks, once that's fixed, remove this.
*/
filename = filename.split('.');
filename.forEach(function (name, idx) {
filename[idx] = utils.slugify(name);
@@ -100,7 +101,8 @@ file.existsSync = function (path) {
var exists = false;
try {
exists = fs.statSync(path);
} catch(err) {
}
catch (err) {
exists = false;
}
@@ -110,7 +112,8 @@ file.existsSync = function (path) {
file.link = function link(filePath, destPath, cb) {
if (process.platform === 'win32') {
fs.link(filePath, destPath, cb);
} else {
}
else {
fs.symlink(filePath, destPath, 'file', cb);
}
};
@@ -120,4 +123,12 @@ file.linkDirs = function linkDirs(sourceDir, destDir, callback) {
fs.symlink(sourceDir, destDir, type, callback);
};
file.typeToExtension = function (type) {
var extension;
if (type) {
extension = '.' + mime.extension(type);
}
return extension;
};
module.exports = file;