Skip to content

Commit 25473e8

Browse files
committed
can use handler event
1 parent 240a30c commit 25473e8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,24 @@ Other options and their default values:
275275
}
276276
```
277277

278+
Use event:
279+
[full sample](https://github.com/Pechalka/file_upload_demo)
280+
281+
```javascript
282+
var doc_id = req.url.split('/')[1]; // /uploads/2 => 2 - doc_id
283+
upload.fileHandler({
284+
uploadDir: __dirname + '/../public/uploads/' + doc_id,
285+
uploadUrl: '/../uploads/' + doc_id
286+
})(req, res)
287+
.on('end', function(fileInfo){
288+
add_file(fileInfo.name, doc_id);
289+
})
290+
.on('delete', function(file_name){
291+
remove_fie(file_name, doc_id);
292+
})
293+
```
294+
295+
278296
## Contributors
279297

280298
* [@soomtong](http://github.com/soomtong)

lib/filehandler.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,7 @@ module.exports = function (middleware, options) {
5353
default:
5454
res.send(405);
5555
}
56+
57+
return handler;
5658
}
5759
};

0 commit comments

Comments
 (0)