Calculating a hash of the file's content while it uploads
- Dominant language
- JavaScript
- Stars
- 12.1k
- Forks
- 1.1k
- Avg merge
- 8d 2h
- Merged PRs (30d)
- 21
Description
I want to generate a hash of the file's content while it is being uploaded. Can I hook in and observe the [file stream](https://github.com/expressjs/multer/blob/master/storage/disk.js#L40) somehow? And then possibly stow this information somewhere? [This other issue is asking for something similar](https://github.com/expressjs/multer/issues/211).
Here's what I'd like to do with the stream:
``` javascript
var crypto = require('crypto');
var path = require('path');
// ...
var hash = crypto.createHash('sha256');
file.stream.on('data', function(chunk) { hash.update(chunk) })
file.stream.on('end', function() {
var sha256 = hash.digest('hex');
// ... look it up in the database, etc
})
```
Contributor guide
Assessment
This issue has not been assessed yet.