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
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);
Creating a new File
var parameters = {
fileToCreate: {
//A Valid JSON Object
},
//Optional topic unique identifier.
topicUid: "uniquetopicid"
}
mediator.publish("wfm:files:create", parameters);
List All files
var parameters = {
userId : "userId"
//Optional topic unique identifier.
topicUid: "uniquetopicid"
}
mediator.publish("wfm:files:list", parameters);
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);
Base url : /file/wfm
resource | method | returns |
---|---|---|
/all | GET | array of files |
/owner/:owner | GET | filtered array of files |
/owner/:owner/upload/base64/:filename | POST | file metadata |
/upload/binary | POST | file metadata |
{
owner: req.params.owner,
name: req.params.filename,
uid: uuid.create().toString()
}
By default file module would store files in filesystem temporary folder.
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);
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);