docs: function addMediaToBuffer (uri, cert, mode, user, safe, bufferURI) {
    // var bufferPath = root
    // if (bufferURI) {
    //  bufferPath += '/../' + url.parse(bufferURI).path
    // }
  
    setTimeout(() => {
      try {
        // fs.unlinkSync(lastFile)
      } catch (e) {
        console.error(e)
      }
      var params = {}
      params.reviewer = user
      if (safe && safe === 'off') {
        params.safe = 0
      } else {
        params.safe = 1
      }
      algos.getRandomUnseenImage.function(params).then(function (row) {
        debug('unseen', row.ret)
        var cacheURI = row.ret[0][0].cacheURI
        var filePath = cacheURI.substr('file://'.length)
        debug('copying', filePath)
  
        // copyMedia(filePath, bufferPath + urlencode(cacheURI), function (err) {
        copyMedia(filePath, bufferURI + urlencode(cacheURI), cert, function (err) {
          if (err) {
            debug(err)
          } else {
            console.log('success!')
            // pay
            var credit = {}
            credit['https://w3id.org/cc#source'] = user
            credit['https://w3id.org/cc#amount'] = algos.getRandomUnseenImage.cost
            credit['https://w3id.org/cc#currency'] = 'https://w3id.org/cc#bit'
            credit['https://w3id.org/cc#destination'] = algos.getRandomUnseenImage.counterparty
            debug(credit)
            pay(credit)
  
            if (row && row.conn) {
              row.conn.close()
            }
          }
        })
      })
    }, 500)
  }