0.4.0 • Published 7 years ago

fh-wfm-file v0.4.0

Weekly downloads
14
License
MIT
Repository
github
Last release
7 years ago

FeedHenry RainCatcher file Build Status

A module for FeedHenry RainCatcher that manages files. It provides :

  • Backend services that expose REST endpoints to create and read operations for files .
  • Services providing a REST client for files.

See raincatcher-file-angular module for angular client side implementation

Client-side usage

This module is packaged in a CommonJS format, exporting the name of the Angular namespace. The module can be included in an angular.js as follows:

var fileCore = require('fh-wfm-file/lib/client');
fileCore(mediator,{},$fh);

Topic Subscriptions

wfm:files:create

Description

Creating a new File

Example
var parameters = {
  fileToCreate: {
    //A Valid JSON Object
  },
  //Optional topic unique identifier.
  topicUid: "uniquetopicid"
}

mediator.publish("wfm:files:create", parameters);

wfm:files:list

Description

List All files

Example
var parameters = {
  userId : "userId"
  //Optional topic unique identifier.
  topicUid: "uniquetopicid"
}

mediator.publish("wfm:files:list", parameters);

Usage in an express backend

The server-side component of this WFM module exports a function that takes express and mediator instances as parameters, as in:

var express = require('express')
  , app = express()
  , mbaasExpress = mbaasApi.mbaasExpress()
  , mediator = require('fh-wfm-mediator/lib/mediator')
  ;

// configure the express app
...

// setup the wfm user router
require('fh-wfm-file/lib/cloud')(mediator, app);

Exposed endpoints

Base url : /file/wfm

resourcemethodreturns
/allGETarray of files
/owner/:ownerGETfiltered array of files
/owner/:owner/upload/base64/:filenamePOSTfile metadata
/upload/binaryPOSTfile metadata

File metadata structure

   {
      owner: req.params.owner,
      name: req.params.filename,
      uid: uuid.create().toString()
   }

Supported storage engines

By default file module would store files in filesystem temporary folder.

AWS S3 storage

Allows to store files in AWS S3 buckets.

Options:

var storageConfig = {
  s3: {
    s3Options: {
      accessKeyId: process.env.AWS_S3_ACCESS_KEY,
      secretAccessKey: process.env.AWS_S3_ACCESS_KEY_SECRET,
      region: process.env.AWS_S3_REGION
    },
    bucket: "raincatcher-files"
  }
}
require('fh-wfm-file/lib/cloud')(mediator, storageConfig);

Gridfs MongoDB storage

Allows to store file in MongoDB database using Gridfs driver

Options:

var storageConfig = {
  gridFs: {
    mongoUrl: "mongodb://localhost:27017/files"
  }
};
require('fh-wfm-file/lib/cloud')(mediator, storageConfig);
1.0.0-pre.1

7 years ago

0.4.0

7 years ago

0.4.0-pre.6

7 years ago

0.4.0-pre.5

7 years ago

0.4.0-pre.4

7 years ago

0.4.0-pre.3

7 years ago

0.4.0-pre.2

7 years ago

0.4.0-pre.1

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.2.0-pre.4

7 years ago

0.2.0-pre.3

7 years ago

0.2.0-pre.2

7 years ago

0.2.0-pre.1

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.10-alpha.1

7 years ago

0.0.9

7 years ago

0.0.9-alpha.3

7 years ago

0.0.9-alpha.2

7 years ago

0.0.9-alpha.1

7 years ago

0.0.8-alpha.1

7 years ago

0.0.7

7 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago