bin/view.js
function getMediaByHTTP (uri, cert, mode, user, safe, bufferURI) {
  return new Promise(function (resolve, reject) {
    var cookiePath = __dirname + '/../data/cookie.json'

    var cookies = readCookie(cookiePath)

    if (cookies) {
      options.headers['Set-Cookie'] = 'connect.sid=' + sid + '; Path=/; HttpOnly; Secure'
    }

    var options = {
      url: uri,
      key: fs.readFileSync(cert),
      cert: fs.readFileSync(cert),
      headers: { // We can define headers too
        'Accept': 'application/json'
      }
    }

    request.get(options, function (error, response, body) {
      writeCookie(response, cookiePath)

      if (!error && response.statusCode === 200) {
        json = JSON.parse(body)
        resolve(json)
      } else {
        reject(error)
      }
    })
  })
}
function getMediaByHTTP (uri, cert, mode, user, safe, bufferURI) {
  return new Promise(function (resolve, reject) {
    var cookiePath = __dirname + '/../data/cookie.json'

    var cookies = readCookie(cookiePath)

    if (cookies) {
      options.headers['Set-Cookie'] = 'connect.sid=' + sid + '; Path=/; HttpOnly; Secure'
    }

    var options = {
      url: uri,
      key: fs.readFileSync(cert),
      cert: fs.readFileSync(cert),
      headers: { // We can define headers too
        'Accept': 'application/json'
      }
    }

    request.get(options, function (error, response, body) {
      writeCookie(response, cookiePath)

      if (!error && response.statusCode === 200) {
        json = JSON.parse(body)
        resolve(json)
      } else {
        reject(error)
      }
    })
  })
}
function getMediaByHTTP ( uri , cert , mode , user , safe , bufferURI ) { return new Promise ( function ( resolve , reject ) { var cookiePath = __dirname + '/../data/cookie.json' var cookies = readCookie ( cookiePath ) if ( cookies ) { options . headers [ 'Set-Cookie' ] = 'connect.sid=' + sid + '; Path=/; HttpOnly; Secure' } var options = { url : uri , key : fs . readFileSync ( cert ) , cert : fs . readFileSync ( cert ) , headers : { // We can define headers too 'Accept' : 'application/json' } } request . get ( options , function ( error , response , body ) { writeCookie ( response , cookiePath ) if ( ! error && response . statusCode === 200 ) { json = JSON . parse ( body ) resolve ( json ) } else { reject ( error ) } } ) } ) }
Get Media item from HTTP
@param  {string} uri       The uri to get it from.
@param  {string} cert      Location of an X.509 cert.
@param  {string} mode      Mode api | http | buffer.
@param  {string} user      The WebID of the user.
@param  {number} safe      Whether safe search is on.
@param  {string} bufferURI The URI of the buffer.
@return {object}           Promise with the row.
Get Media item from HTTP