开发者社区> 镜像站> NPM> ssb-blob-files
ssb-blob-files
handle processing and addition of files to the blob store
Last updated 6 months ago by arj03 .
AGPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ssb-blob-files 
SYNC missed versions from official npm registry.

ssb-blob-files

Channel a bunch of files from a dom event into the blob store. Get some tweaks and checks made along the way.

Usage

var h = require('mutant/h')
var blobFiles = require('ssb-blob-files')

var opts = {
  stripExif: true,
  resize: { width: 640, height: 480 },
  isPrivate: true
}

var fileInput = h('input', {
  type: 'file',
  attributes: { multiple: true }, // permit multiple files to be attached
  'ev-change': (ev) => {
    var files = ev.target.files
    blobFiles(files, server, opts, (err, result) => {  // server is a connection to scuttlebutt server
      ev.target.value = ''

      if (err) console.log('oh noes') 
      else // do something with the result data
    }
  })
})

API

blobFiles(files, server, opts cb)

files - an Array of files of the format delivered by file input events

server - a connection to a scuttlebot server (either an ssb-client instance, or an observeable which resolves to one)

opts - (optional) an options Object of the form:

{
  stripExif: Boolean,   // (default: false) removes exif data from images (geo-location, camera meta data, etc)
  resize: Object,       // (default: undefined) resizes image if possible. Expected properties: width, height
  quality: Number,      // (default: 0.85) tune the compression of jpegs. value between 0 and 1
  isPrivate: Boolean    // (default: false) encrypts the blob
}

If a blob is private, it gets encryted and the unbox key is attached to the end of the link property in the result output (see cb details)

cb - a callback with signature (err, result) which is run for each file that is processed. The shape of the result object is

{
  link: BlobId,  // hash id in the blob store, will have an unbox key on the end if isPrivate was true
  name: String,  // the filename
  size: Integer, // size in bytes
  type: String   // the MimeType
}

Current Tags

  • 1.2.1                                ...           latest (6 months ago)

10 Versions

  • 1.2.1                                ...           6 months ago
  • 1.2.0                                ...           a year ago
  • 1.1.6                                ...           2 years ago
  • 1.1.5                                ...           2 years ago
  • 1.1.4                                ...           2 years ago
  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (7)
Dev Dependencies (2)