<commit_before>var u = require('../util')
var h = require('hyperscript')
var pull = require('pull-stream')
var mime = require('mime-types')
var split = require('split-buffer')

var plugs = require('../plugs')

var add = plugs.first(exports.sbot_blobs_add = [])

exports.file_input = function FileInput(onAdded) {

  return h('input', { type: 'file',
    onchange: function (ev) {
      var file = ev.target.files[0]
      var reader = new FileReader()
      reader.onload = function () {
        pull(
          pull.values(split(new Buffer(reader.result), 64*1024)),
          add(function (err, blob) {
            if(err) return console.error(err)
            onAdded({
              link: blob,
              name: file.name,
              size: reader.result.length || reader.result.byteLength,
              type: mime.contentType(file.name)
            })

          })
        )
      }
      reader.readAsArrayBuffer(file)
    }
  })
}




<commit_msg>use a way smaller mime module<commit_after>var u = require('../util')
var h = require('hyperscript')
var pull = require('pull-stream')
var mime = require('simple-mime')('application/octect-stream')
var split = require('split-buffer')

var plugs = require('../plugs')

var add = plugs.first(exports.sbot_blobs_add = [])

exports.file_input = function FileInput(onAdded) {

  return h('input', { type: 'file',
    onchange: function (ev) {
      var file = ev.target.files[0]
      var reader = new FileReader()
      reader.onload = function () {
        pull(
          pull.values(split(new Buffer(reader.result), 64*1024)),
          add(function (err, blob) {
            if(err) return console.error(err)
            onAdded({
              link: blob,
              name: file.name,
              size: reader.result.length || reader.result.byteLength,
              type: mime(file.name)
            })

          })
        )
      }
      reader.readAsArrayBuffer(file)
    }
  })
}

{'fraction_non_alphanumeric': 0.14190573770491804, 'fraction_numerical': 0.007172131147540984, 'mean_word_length': 2.206896551724138, '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': '5409710', 'n_tokens_mistral': 616, 'n_tokens_neox': 590, 'n_words': 127}