1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var fs = require("fs"),
|
7 | path = require("path"),
|
8 | utils = require("../lib/utils");
|
9 |
|
10 |
|
11 | var Model = function( options ){
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | this.options = options;
|
18 |
|
19 | }
|
20 |
|
21 | Model.prototype = {
|
22 |
|
23 | constructor: Model,
|
24 |
|
25 | create: function( data, callback ){
|
26 |
|
27 |
|
28 | var dir = path.dirname( data.destination );
|
29 | if ( !fs.existsSync( dir ) ) utils.mkdir( dir );
|
30 |
|
31 | fs.createReadStream( data.source ).pipe( fs.createWriteStream( data.destination ) )
|
32 | .on("finish", function(){
|
33 |
|
34 | callback(true);
|
35 | });
|
36 | },
|
37 |
|
38 | read: function( file, callback ){
|
39 | var source = this.options.path + file;
|
40 | return fs.createReadStream( source ).pipe();
|
41 | },
|
42 |
|
43 | update: function( query, callback ){
|
44 |
|
45 | },
|
46 |
|
47 | destroy: function( item, callback ){
|
48 |
|
49 | }
|
50 |
|
51 | }
|
52 |
|
53 |
|
54 | module.exports = Model; |
\ | No newline at end of file |