开发者社区> 镜像站> NPM> ssb-serve-blobs
ssb-serve-blobs
Serve blobs from a local http server
Last updated 3 months ago by staltz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ssb-serve-blobs 
SYNC missed versions from official npm registry.

ssb-serve-blobs

Scuttlebot plugin to serve blobs from a local http server on port 26835.

Note also this remark plugin for modifying markdown to link to the server: remark-images-to-ssb-serve-blobs

usage

Requires ssb-blobs plugin.

 const createSbot = require('scuttlebot/index')
   .use(require('scuttlebot/plugins/plugins'))
   .use(require('scuttlebot/plugins/master'))
   .use(require('scuttlebot/plugins/gossip'))
   .use(require('scuttlebot/plugins/replicate'))
   .use(require('ssb-friends'))
+  .use(require('ssb-blobs'))
   .use(require('ssb-backlinks'))
   .use(require('ssb-private'))
   .use(require('ssb-about'))
   .use(require('ssb-query'))
+  .use(require('ssb-serve-blobs'))
   .use(require('scuttlebot/plugins/invite'))
   .use(require('scuttlebot/plugins/block'))
   .use(require('scuttlebot/plugins/local'))

Example usage

const Stack = require('secret-stack')
const caps = require('ssb-caps')


const stack = Stack({ caps })
  .use(require('ssb-db'))          // << required
  .use(require('ssb-blobs'))
  .use(require('ssb-serve-blobs')) // needs: blobs

const config = {
   // see ssb-config for other needed config
   serveBlobs: {
      cors: true, // enable cors
      csp: "default-src 'self';", // set the content security policy (default: 'default-src none; sandbox')
      port: 3921 // set the port to serve blobs from (default: 26835)
   }
}
const server = stack(config)

utils

const toUrl = require('ssb-serve-blobs/id-to-url')

const blobId = '&d8kM9RXf5zvvy+AzlQ//JbCF0AEJelTl6m03u3dVVj4=.sha256'
const unboxKey = 'uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek='

console.log(toUrl(blobId));
// http://localhost:26835/%26d8kM9RXf5zvvy%2BAzlQ%2F%2FJbCF0AEJelTl6m03u3dVVj4%3D.sha256

console.log(toUrl(blobId, { unbox: unboxKey }));
// http://localhost:26835/%26d8kM9RXf5zvvy%2BAzlQ%2F%2FJbCF0AEJelTl6m03u3dVVj4%3D.sha256?unbox=uU0nuZNNPgilLlLX2n2r%2BsSE7%2BN6U4DukIj3rOLvzek%3D
const fromUrl = require('ssb-serve-blobs/url-to-id')

console.log(fromUrl('http://localhost:26835/%26Pe5kTo%2FV%2Fw4MToasp1IuyMrMcCkQwDOdyzbyD5fy4ac%3D.sha256'));
// &Pe5kTo/V/w4MToasp1IuyMrMcCkQwDOdyzbyD5fy4ac=.sha256

License

MIT

Current Tags

  • 2.5.0                                ...           latest (3 months ago)

7 Versions

  • 2.5.0                                ...           3 months ago
  • 2.4.0                                ...           5 months ago
  • 2.3.0                                ...           6 months ago
  • 2.2.0                                ...           6 months ago
  • 2.1.0                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.0                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 2
Last Month 3
Dependencies (5)
Dev Dependencies (4)