How to use the mime.Mime function in mime

To help you get started, we’ve selected a few mime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kriskowal / narwhal-lib / lib / jack / file.js View on Github external
var Utils = require("utils"),
    Mime = require("mime").Mime;

var Jack_File = exports.File = function(root) {
    return function(env) {
        var pathInfo = Utils.unescape(env["PATH_INFO"]);

        if (pathInfo.indexOf("..") >= 0)
            return Jack_File.forbidden();

        var path = pathInfo ? File.join(root, pathInfo) : root; // don't want to append a "/" if PATH_INFO is empty

        try {
            if (File.isReadable(path)) {
                // efficiently serve files if the server supports "X-Sendfile"
                if (false && env["HTTP_X_ALLOW_SENDFILE"]) {
                    return [200, {
                        "X-Sendfile"        : path,
github node-tastypie / tastypie / lib / mime.js View on Github external
* @since 0.1.0
 * @requires accepts
 * @requires mime
 * @requires mime/types
 * @requires mout/array/intersection
 */

var accepts      = require( 'accepts' )
  , mime         = require( 'mime' )
  , intersection = require( 'mout/array/intersection' )
  , types        = require('mime/types')
  ;

const EMPTY_STRING = '';

class Mime extends mime.Mime {

	constructor(){
		super();
		this.default_type = null;
		this.define( types );
	}

	lookup( format, fallback ){
		return super.lookup( format || EMPTY_STRING, fallback );
	}

	extension( ext ){
		return super.extension( ext || EMPTY_STRING );
	}
	/**
	 * best guess determination of request mime type from Accept header