<commit_before>/**
 * Created by daniel.joppi on 12/4/14.
 */

module.exports = function(router, db) {
    var mongo = require('mongodb');
    var Grid = require('gridfs-stream');

    var gfs = Grid(db, mongo);

    // upload image
    router.post('/image', function (req, res) {
        var data = req.body;
        var stream = gfs.createWriteStream({
            filename: data.filename,
            contentType: data.type
        });
        req.pipe(stream);
        res.send(stream);
    });

    // get image to url
    router.get('/image/:id', function (req, res) {
        var stream = gfs.createReadStream({
            _id: req.params.id
        });
        //error handling, e.g. file does not exist
        stream.on('error', function (err) {
            console.log('An error occurred!', err);
            throw err;
        });
<commit_msg>populate records<commit_after>/**
 * Created by daniel.joppi on 12/4/14.
 */

module.exports = function(router, db) {
    var mongo = require('mongodb');
    var Grid = require('gridfs-stream');

    var gfs = Grid(db, mongo);

    // upload image
    router.post('/image', function (req, res) {
        var data = req.body;
        var stream = gfs.createWriteStream({
            filename: data.filename,
            contentType: data.type
        });
        req.pipe(stream);
        res.send(stream);
    });

    // get image to url
    router.get('/image/:id', function (req, res) {
        var stream = gfs.createReadStream({
            _id: req.params.id
        });
        //error handling, e.g. file does not exist
        stream.on('error', function (err) {
            console.log('An error occurred!', err);
            throw err;
        });

        res.header("Content-Type", stream.contentType);
{'fraction_non_alphanumeric': 0.14511575381140598, 'fraction_numerical': 0.00564652738565782, 'mean_word_length': 1.9289256198347107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5485570', 'n_tokens_mistral': 540, 'n_tokens_neox': 526, 'n_words': 135}