Skip to content

Instantly share code, notes, and snippets.

@noppolp
Created May 17, 2015 09:11
Show Gist options
  • Select an option

  • Save noppolp/c13d2c581da726901ee5 to your computer and use it in GitHub Desktop.

Select an option

Save noppolp/c13d2c581da726901ee5 to your computer and use it in GitHub Desktop.
FileInfo for NodeJS
var fs = require('fs');
var path = require('path');
var mime = require('mime');
var FileInfo = function (fullPath) {
if (fs.existsSync(fullPath)) {
this.fullPath = fullPath;
var stats = fs.statSync(fullPath);
this.size = stats["size"];
this.name = path.basename(fullPath);
this.contentType = mime.lookup(fullPath);
}
};
FileInfo.prototype.fullPath = "";
FileInfo.prototype.name = "";
FileInfo.prototype.size = 0;
FileInfo.prototype.contentType = "";
module.exports = FileInfo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment