file-handler
Advanced tools
Comparing version 0.0.1 to 0.0.2
22
index.js
var mongoose = require('mongoose'); | ||
var gm = require('gm'); | ||
var fmFilesSchema = mongoose.Schema({ | ||
@@ -17,6 +18,23 @@ }); | ||
if (err) callback(false); | ||
else callback('/api/file/' + file._id + ".png"); | ||
else callback('/api/file/' + file._id + ".png", file._id); | ||
}); | ||
}); | ||
}; | ||
module.exports.deleteImage = function(id, callback) { | ||
var path = root + "/" + id + ".png"; | ||
fs.unlink(path, function(err){ | ||
if(err) throw err; | ||
console.log("file deleted"); | ||
}) | ||
}; | ||
module.exports.createSvg = function(svg, callback) { | ||
FmFile.create({}, function(err, file) { | ||
var path = root + "/" + file._id + ".svg"; | ||
fs.writeFile(path, svg, function(err) { | ||
if (err) callback(false); | ||
else callback('/api/file/' + file._id + ".svg"); | ||
}); | ||
}); | ||
} | ||
module.exports.config = function(config) { | ||
@@ -27,2 +45,2 @@ root = config.root; | ||
res.sendFile(root + '/' + req.params.fileID) | ||
}; | ||
}; |
{ | ||
"name": "file-handler", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Is an project which will support saving file local on the server and multiple server, same way will support remote save with remote backup.", | ||
@@ -10,2 +10,5 @@ "license": "MIT", | ||
"email": "crackeraki@gmail.com" | ||
},{ | ||
"name": "Sergey Bugai", | ||
"email": "SergeyBugai@gmail.com" | ||
}], | ||
@@ -23,2 +26,2 @@ "engines": { | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3517
41