lib/util.js
function putStorage(host, path, data, cert, callback) {
  var protocol = 'https://'

  var ldp = {
    hostname: host,
    rejectUnauthorized: false,
    port:     443,
    method:   'PUT',
    headers:  {'Content-Type': 'text/turtle'}
  }

  if (cert) {
    ldp.key = fs.readFileSync(cert)
    ldp.cert = fs.readFileSync(cert)
  }

  // put file to ldp
  ldp.path = path
  debug('sending to : ' + protocol + host + path)
  var put = https.request(ldp, function(res) {
    chunks = ''
    debug('STATUS: ' + res.statusCode)
    debug('HEADERS: ' + JSON.stringify(res.headers))
    res.on('data', function (chunk) {
      chunks += chunk
    })
    res.on('end', function (chunk) {
      callback(null, chunks, ldp)
    })
  })

  put.on('error', function(e) {
    callback(e)
  })

  put.write(data)
  put.end()
}
function putStorage(host, path, data, cert, callback) {
  var protocol = 'https://'

  var ldp = {
    hostname: host,
    rejectUnauthorized: false,
    port:     443,
    method:   'PUT',
    headers:  {'Content-Type': 'text/turtle'}
  }

  if (cert) {
    ldp.key = fs.readFileSync(cert)
    ldp.cert = fs.readFileSync(cert)
  }

  // put file to ldp
  ldp.path = path
  debug('sending to : ' + protocol + host + path)
  var put = https.request(ldp, function(res) {
    chunks = ''
    debug('STATUS: ' + res.statusCode)
    debug('HEADERS: ' + JSON.stringify(res.headers))
    res.on('data', function (chunk) {
      chunks += chunk
    })
    res.on('end', function (chunk) {
      callback(null, chunks, ldp)
    })
  })

  put.on('error', function(e) {
    callback(e)
  })

  put.write(data)
  put.end()
}
function putStorage ( host , path , data , cert , callback ) { var protocol = 'https://' var ldp = { hostname : host , rejectUnauthorized : false , port : 443 , method : 'PUT' , headers : { 'Content-Type' : 'text/turtle' } } if ( cert ) { ldp . key = fs . readFileSync ( cert ) ldp . cert = fs . readFileSync ( cert ) } // put file to ldp ldp . path = path debug ( 'sending to : ' + protocol + host + path ) var put = https . request ( ldp , function ( res ) { chunks = '' debug ( 'STATUS: ' + res . statusCode ) debug ( 'HEADERS: ' + JSON . stringify ( res . headers ) ) res . on ( 'data' , function ( chunk ) { chunks += chunk } ) res . on ( 'end' , function ( chunk ) { callback ( null , chunks , ldp ) } ) } ) put . on ( 'error' , function ( e ) { callback ( e ) } ) put . write ( data ) put . end ( ) }
putStorage Sends turtle data to remote storage via put request
@param  {String}   host     The host to send to
@param  {String}   path     The path relative to host
@param  {String}   data     The turtle to send
@param  {String}   cert     Certificate path used for auth
@param  {Function} callback Callback with error or response
putStorage Sends turtle data to remote storage via put request