Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow reading the properties from a URL #18

Open
masalomon opened this issue Apr 23, 2018 · 1 comment
Open

Allow reading the properties from a URL #18

masalomon opened this issue Apr 23, 2018 · 1 comment

Comments

@masalomon
Copy link

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?

@steveukx
Copy link
Owner

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
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants