Giter VIP home page Giter VIP logo

al-file-system-watcher's Introduction

al-file-system-watcher

Supports a method to watch a particular directory for files with a particular extension. Any files that are added will be automatically read and uploaded to AwardLetter files API.

By default, activity is logged to a file within ./logs/alfilesystemwatcher.log using nodejs winston module. This can be modified to log to numerous sources including a database or a SaaS logging product.

Note that this script expects any added files to be available in whole. When copying large files into the source directory, it is best to save it with an extension that is different from the watched extension. Once the file has been copied in full, rename the extension to the watched extension.


Environment Requirements:

  • SSL access to the public internet over port 5443.
  • Node.js installed.

Installing directly from github:

Clone or download as zip to local machine. For the later, unzip to desired location. Install the following dependencies via npm (npm install [module-name]):

  • chokidar
  • winston
  • oath-wrap
  • al-files-service
  • promise

Configuration:

All configuration is contained within the config.json file.

Logging: The module is configured to log to a logs folder within the root directory of the application. Standard log entries will be written to a file named alfilesystemwatcher.log while unhandled exceptions will be logged to a file named alfilesystemwatchererrors.log.

  "logging" : { "directory" : "./logs" }

Authorization: The upload process requires an authorization token from a secure token service(STS).

  "oauthWrapRequest" : { "url":"sts_url", "creds":{"uid":"userid", "pwd":"password"}, "wrapScope":"scope" }

The following values must be provided in order to invoke the STS and acquire an authorization token:

JSON Element Description
url The STS URL
creds.userid User Id
creds.pwd User password
wrapScope The resource that will be accessed using the authorization token.

AwardLetter Files API: Defines the root URL of the AwardLetter Files API. This API defines a method for uploading AwardLetter input file content.

  "filesApi" : { "rootUrl" : "root_url" }

Watch Settings: Defines the directory to be watched, the file extension to look for, as well as the expected file format/extension.

  "watch" : { "directory" : "./source", "extension" : "json", "fileFormat" : "txt" }

###Running alfilesystemwatcher:

From the alfilesystemwatcher root directory, execute the following in a command prompt:

  node alfilesystemwatcher.js

Alternatively, alfilesystemwatcher can be run as a daemon process using the nodejs forever module.

  • Install forever by executing "npm install forever -g" in a command prompt.
  • Run alfilesystemwatcher using forever by executing "forever start alfilesystemwatcher.js" in a command prompt.

al-file-system-watcher~watch(config)

Automatically upload files that are created within a designated source directory.

Kind: inner method of al-file-system-watcher

Param Type Description
config object Contains values for 1) directory to watch and 2) file extension to watch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.