properties icon indicating copy to clipboard operation
properties copied to clipboard

Allow reading the properties from a URL

Open masalomon opened this issue 6 years ago • 1 comments

The current implementation, using the fs module, allows the properties file to be read only from the local file system. A use case I came across needed to access the properties file across a network, via http/https. Could this be added easily enough, or is it too much work or not appropriate?

masalomon avatar Apr 23 '18 19:04 masalomon

Hi, while it's not explicitly permitted in the API - you can replace the content of the properties using the read( properties: string ): void method, for example:

const reader = require('properties-reader');
const request = require('request');

const properties = reader(`${__dirname}/some.properties`);
request('http://server.com/properties.ini', (err, res) => {
  if (res) {
    properties.read( res ); // assumes res is an ini file format, appends it into the reader
  }
});

steveukx avatar Apr 24 '18 14:04 steveukx