{"_id":"file-api","_rev":"4652700","name":"file-api","description":"HTML5 FileAPI for Node.js","dist-tags":{"latest":"0.10.4"},"maintainers":[{"name":"coolaj86","email":""},{"name":"narf","email":""}],"time":{"modified":"2026-04-10T20:48:29.000Z","created":"2011-01-12T00:01:31.882Z","0.10.4":"2014-10-24T20:26:24.788Z","0.10.3":"2014-10-24T20:22:07.468Z","0.10.2":"2014-10-24T19:50:27.643Z","0.10.1":"2014-10-20T01:11:42.111Z","0.9.3":"2011-03-02T19:28:41.600Z","0.9.2":"2011-02-16T02:55:04.729Z","0.9.1":"2011-01-13T22:35:36.632Z","0.9.0":"2011-01-12T00:01:31.882Z"},"users":{},"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com"},"versions":{"0.10.4":{"name":"file-api","description":"HTML5 FileAPI for Node.js","url":"http://github.com/node-file-api/file-api","keywords":["html5","jsdom","file-api"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com"},"contributors":[],"dependencies":{"bufferjs":"> 0.2.0","File":">= 0.10.0","FileList":">= 0.10.0","file-error":">= 0.10.0","filereader":">= 0.10.3","formdata":">= 0.10.0","mime":">= 1.2.11","remedial":">= 1.0.7"},"main":"./index","version":"0.10.4","_id":"file-api@0.10.4","_shasum":"2f101226db727cc0172a0dd688f2f6883d52883d","_from":"./","_npmVersion":"1.4.9","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"maintainers":[{"name":"coolaj86","email":""},{"name":"narf","email":""}],"dist":{"shasum":"2f101226db727cc0172a0dd688f2f6883d52883d","size":7119,"noattachment":false,"key":"/file-api/-/file-api-0.10.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/file-api/download/file-api-0.10.4.tgz"},"directories":{},"publish_time":1414182384788,"_hasShrinkwrap":false,"_cnpm_publish_time":1414182384788,"_cnpmcore_publish_time":"2021-12-16T20:56:26.296Z"},"0.10.3":{"name":"file-api","description":"HTML5 FileAPI for Node.js","url":"http://github.com/node-file-api/file-api","keywords":["html5","jsdom","file-api"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com"},"contributors":[],"dependencies":{"bufferjs":"> 0.2.0","File":">= 0.10.0","FileList":">= 0.10.0","file-error":">= 0.10.0","filereader":">= 0.10.3","formdata":">= 0.10.0","mime":">= 1.2.11","remedial":">= 1.0.7"},"main":"./index","version":"0.10.3","_id":"file-api@0.10.3","_shasum":"8a2ed8847f5a4948da5c65bfca36667d3f99d1bf","_from":"./","_npmVersion":"1.4.9","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"maintainers":[{"name":"coolaj86","email":""},{"name":"narf","email":""}],"dist":{"shasum":"8a2ed8847f5a4948da5c65bfca36667d3f99d1bf","size":7125,"noattachment":false,"key":"/file-api/-/file-api-0.10.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/file-api/download/file-api-0.10.3.tgz"},"directories":{},"publish_time":1414182127468,"_hasShrinkwrap":false,"_cnpm_publish_time":1414182127468,"_cnpmcore_publish_time":"2021-12-16T20:56:26.525Z"},"0.10.2":{"name":"file-api","description":"HTML5 FileAPI for Node.JS.","url":"http://github.com/coolaj86/node-file-api/","keywords":["html5","jsdom","file-api"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com"},"contributors":[],"dependencies":{"bufferjs":"> 0.2.0","noop":">= 0.1.0","futures":">= 1.9.4","File":">= 0.10.0","FileList":">= 0.10.0","FileError":">= 0.10.0","filereader":">= 0.10.3","FormData":">= 0.10.0","mime":">= 1.2.11","remedial":">= 1.0.7"},"main":"./index","version":"0.10.2","_id":"file-api@0.10.2","_shasum":"fb646fc12713d60b125c9987368e1fa789157902","_from":"./","_npmVersion":"1.4.9","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"maintainers":[{"name":"coolaj86","email":""},{"name":"narf","email":""}],"dist":{"shasum":"fb646fc12713d60b125c9987368e1fa789157902","size":747,"noattachment":false,"key":"/file-api/-/file-api-0.10.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/file-api/download/file-api-0.10.2.tgz"},"directories":{},"publish_time":1414180227643,"_hasShrinkwrap":false,"_cnpm_publish_time":1414180227643,"_cnpmcore_publish_time":"2021-12-16T20:56:26.793Z"},"0.10.1":{"name":"file-api","description":"HTML5 FileAPI for Node.JS.","url":"http://github.com/coolaj86/node-file-api/","keywords":["html5","jsdom","file-api"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com"},"contributors":[],"dependencies":{"bufferjs":"> 0.2.0","noop":">= 0.1.0","futures":">= 1.9.4","File":">= 0.10.0","FileList":">= 0.10.0","FileError":">= 0.10.0","FileReader":">= 0.10.0","FormData":">= 0.10.0","mime":">= 1.2.11","remedial":">= 1.0.7"},"main":"./index","version":"0.10.1","_id":"file-api@0.10.1","_shasum":"f85b7d05143ef4ebc11121cbc26c2128559b5c6c","_from":"./","_npmVersion":"1.4.9","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"maintainers":[{"name":"coolaj86","email":""},{"name":"narf","email":""}],"dist":{"shasum":"f85b7d05143ef4ebc11121cbc26c2128559b5c6c","size":747,"noattachment":false,"key":"/file-api/-/file-api-0.10.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/file-api/download/file-api-0.10.1.tgz"},"directories":{},"publish_time":1413767502111,"_hasShrinkwrap":false,"_cnpm_publish_time":1413767502111,"_cnpmcore_publish_time":"2021-12-16T20:56:26.981Z"},"0.9.3":{"name":"file-api","description":"HTML5 FileAPI for Node.JS.","url":"http://github.com/coolaj86/node-file-api/","keywords":["html5","jsdom","file-api"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com"},"contributors":[],"dependencies":{"bufferjs":"> 0.2.0","noop":">= 0.1.0","futures":">= 1.9.4"},"main":"./index","version":"0.9.3","_id":"file-api@0.9.3","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"0.2.17","_nodeVersion":"v0.2.5","directories":{},"files":[""],"_defaultsLoaded":true,"dist":{"shasum":"ec17f2513ed777d325ec72fd18800a9a061f7789","size":5346,"noattachment":false,"key":"/file-api/-/file-api-0.9.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/file-api/download/file-api-0.9.3.tgz"},"publish_time":1299094121600,"maintainers":[{"name":"coolaj86","email":""},{"name":"narf","email":""}],"_hasShrinkwrap":false,"_cnpm_publish_time":1299094121600,"_cnpmcore_publish_time":"2021-12-16T20:56:27.172Z"},"0.9.2":{"name":"file-api","description":"HTML5 FileAPI for Node.JS.","url":"http://github.com/coolaj86/node-file-api/","keywords":["html5","jsdom","file-api"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com"},"contributors":[],"dependencies":{"bufferjs":"> 0.1.0","noop":">= 0.1.0","futures":">= 1.9.0"},"lib":"lib","main":"./lib/index","version":"0.9.2","_id":"file-api@0.9.2","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"0.2.17","_nodeVersion":"v0.2.5","directories":{"lib":"./lib"},"files":[""],"_defaultsLoaded":true,"dist":{"shasum":"e7ec4d6c2a475cf651ea5053b46bce73f642cc85","size":533199,"noattachment":false,"key":"/file-api/-/file-api-0.9.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/file-api/download/file-api-0.9.2.tgz"},"publish_time":1297824904729,"maintainers":[{"name":"coolaj86","email":""},{"name":"narf","email":""}],"_hasShrinkwrap":false,"_cnpm_publish_time":1297824904729,"_cnpmcore_publish_time":"2021-12-16T20:56:28.584Z"},"0.9.1":{"name":"file-api","description":"HTML5 FileAPI for Node.JS.","url":"http://github.com/coolaj86/node-file-api/","keywords":["html5","jsdom","file-api"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com"},"contributors":[],"dependencies":{"bufferjs":"> 0.1.0","noop":">= 0.1.0","futures":">= 1.9.0"},"lib":"lib","main":"./lib/index","version":"0.9.1","_id":"file-api@0.9.1","engines":{"node":"*"},"_nodeSupported":true,"_npmVersion":"0.2.3-6","_nodeVersion":"v0.2.0","dist":{"shasum":"63e977474d525fcecd8420019b91482596a0326b","size":268644,"noattachment":false,"key":"/file-api/-/file-api-0.9.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/file-api/download/file-api-0.9.1.tgz"},"directories":{},"publish_time":1294958136632,"maintainers":[{"name":"coolaj86","email":""},{"name":"narf","email":""}],"_hasShrinkwrap":false,"_cnpm_publish_time":1294958136632,"_cnpmcore_publish_time":"2021-12-16T20:56:29.470Z"},"0.9.0":{"name":"file-api","description":"HTML5 FileAPI for Node.JS.","url":"http://github.com/coolaj86/node-file-api/","keywords":["html5","jsdom","file-api"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com"},"contributors":[],"dependencies":{"bufferjs":"> 0.1.0","noop":">= 0.1.0","futures":">= 1.9.0"},"lib":"lib","main":"./lib/index","version":"0.9.0","_id":"file-api@0.9.0","engines":{"node":"*"},"_nodeSupported":true,"_npmVersion":"0.2.3-6","_nodeVersion":"v0.2.0","dist":{"shasum":"d5a171acb2062c16e01ab737f01cb990677184d1","size":261092,"noattachment":false,"key":"/file-api/-/file-api-0.9.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/file-api/download/file-api-0.9.0.tgz"},"directories":{},"publish_time":1294790491882,"maintainers":[{"name":"coolaj86","email":""},{"name":"narf","email":""}],"_hasShrinkwrap":false,"_cnpm_publish_time":1294790491882,"_cnpmcore_publish_time":"2021-12-16T20:56:30.347Z"}},"readme":"file-api\n========\n\nHTML5 FileAPI implemented in Node.js\n\nThe goal here is to be able to use this in connection with `jsdom` to create test utilities,\npossibly scraping utilities, ultimately an API-driven browser written in Node.\n\nUsage\n====\n\nInstall:\n\n```bash\nnpm install file-api\n```\n\nUse:\n\n```javascript\nvar FileAPI = require('file-api')\n  , File = FileAPI.File\n  , FileList = FileAPI.FileList\n  , FileReader = FileAPI.FileReader\n  ;\n```\n\nAPI\n====\n\nSince `HTML5 FileAPI` has been described by the W3C (terse, technical) and Mozilla Developer Center (understandable, end-user-oriented) in detail, I'll just highlight the differences:\n\n  * `File` is not (yet) a subclass of `Blob`\n  * `FileError` and `FileException` are not yet implemented (they use `Error` instead)\n  * `blob: scheme` and remote `URI schemes` are not yet implemented\n\nFormData\n----\n\n[FormData on MDN](https://developer.mozilla.org/en/XMLHttpRequest/FormData)\n\nHas the special method `setNodeChunkedEncoding()`\n\nFile\n----\n\nIn the browser, `File` has no constructor. In Node, it does.\n\n`node-mime` is used for extension-based automatic `ContentType` detection (uses `name` if available, or `path` if not)\n\n**File(StringUriPath)**\n\n    var file = new File(\"./files/myfile.txt\");\n\n**File({ buffer: Node.Buffer })**\n\n    var file = new File({ \n      name: \"abc-song.txt\",   // required\n      type: \"text/plain\",     // optional\n      buffer: new Buffer(\"abcdefg,hijklmnop, qrs, tuv, double-u, x, y and z\")\n    });\n\n**File({ stream: Node.ReadStream })**\n\n    var file = new File({\n      name: \"abc-song.txt\",       // required\n      type: \"text/plain\",         // optional\n      stream: new EventEmitter()  // a read stream (emits `error`, `data`, `end`)\n    });\n\n    process.nextTick(function () {\n      file.stream.emit('data', \"abcdefg,hijklmnop, qrs, tuv, double-u, x, y and z\");\n      file.stream.emit('end');\n    });\n\n**File(Object)**\n\n    var file = new File({\n      path: \"./files/myfile.txt\",   // path of file to read\n\n\n      buffer: Node.Buffer,          // use this Buffer instead of reading file\n\n\n      stream: Node.ReadStream,      // use this ReadStream instead of reading file\n\n\n      name: \"SomeAwesomeFile.txt\",  // optional when using `path`\n                                    // must be supplied when using `Node.Buffer` or `Node.ReadStream`\n\n\n      type: \"text/plain\",           // generated based on the extension of `name` or `path`\n\n\n      jsdom: true,                  // be DoM-like and immediately get `size` and `lastModifiedDate`\n                                    // [default: false]\n\n\n      async: true,                  // use `fs.stat` instead of `fs.statSync` for getting \n                                    // the `jsdom` info\n                                    // [default: false]\n\n\n      lastModifiedDate: fileStat.mtime.toISOString(),\n\n\n      size: fileStat.size || Buffer.length\n    );\n\n\nFileReader\n----\n\n**FileReader.setNodeChunkedEncoding()** is a *non-standard* method which hints that the `FileReader` should chunk if possible\n\nI.E. The file will be sent with the header `Transfer-Encoding: chunked`\n\nThe default is `false` since many webservers do not correctly implement the standard correctly,\nand hence do not expect or accept `Transfer-Encoding: chunked` from clients.\n\n**FileReader.on** is a *non-standard* alias of `addEventListener`\n\n**EventTarget.target.nodeBufferResult** is a *non-standard* property which is a `Node.Buffer` instance of the data.\n\n**FileReader.on('data', fn)** is a *non-standard* event which passes a `Node.Buffer` chunk each time the `progress` event is fired.\n\n    var fileReader = new FileReader();\n\n    fileReader.setNodeChunkedEncoding(true || false);\n    fileReader.readAsDataURL(new File('./files/my-file.txt'));\n\n    // non-standard alias of `addEventListener` listening to non-standard `data` event\n    fileReader.on('data', function (data) {\n      console.log(\"chunkSize:\", data.length);\n    });\n\n    // `onload` as listener\n    fileReader.addEventListener('load', function (ev) {\n      console.log(\"dataUrlSize:\", ev.target.result.length);\n    });\n\n    // `onloadend` as property\n    fileReader.onloadend', function () {\n      console.log(\"Success\");\n    });\n\nFileList\n----\n\nThe browser has no constructor for this. Node has two.\n\n**new FileList(f1, f2, ...)**\n\n    var fileList = new FileList(file1, file2, file3);\n\n**new FileList([f1, f2])**\n\n    var files = [\n        new File('./files/blob.bin'),\n        new File('./files/image.jpg'),\n        new File('./files/readme.txt')\n      ],\n      fileList;\n\n    fileList = new FileList(files);\n\nFormal Documentation\n====\n\nW3C\n\n  * [W3C: FileAPI](http://dev.w3.org/2006/webapi/FileAPI)\n  * [W3C: Blob](http://dev.w3.org/2006/webapi/FileAPI/#dfn-Blob)\n  * [W3C: File](http://dev.w3.org/2006/webapi/FileAPI/#dfn-file)\n  * [W3C: FileList](http://dev.w3.org/2006/webapi/FileAPI/#dfn-filelist)\n  * [W3C: FileReader](http://dev.w3.org/2006/webapi/FileAPI/#dfn-filereader)\n  * [W3C: FileError](http://dev.w3.org/2006/webapi/FileAPI/#dfn-fileerror)\n  * [W3C: URI scheme](http://dev.w3.org/2006/webapi/FileAPI/#url)\n\nMozilla Developer Center:\n\n  * [MDN: Using files from web applications](https://developer.mozilla.org/en/using_files_from_web_applications)\n  * [MDN: File](https://developer.mozilla.org/en/DOM/File)\n  * [MDN: FileList](https://developer.mozilla.org/en/DOM/FileList)\n  * [MDN: FileReader](https://developer.mozilla.org/en/DOM/FileReader)\n\nTODO\n====\n\n    //\n    // TODO\n    //\n    // HTML5 File URI should be implemented\n    //   will need non-ahr 301-handling requester not prevent circular dep\n    //\n    // File should be a subclass of Blob\n    //\n    // jsdom EventTarget // http://aptana.com/reference/html/api/EventTarget.html\n    //    target.result\n    // \n    // jsdom ProgressEvent // http://www.w3.org/TR/progress-events/\n    //    lengthComputable\n    //    loaded\n    //    total\n    //    initProgressEvent\n","_attachments":{}}