Module to abstract storing files on hard drive or in a shared system between multiple countly instances, currently based on GridFS
- Description:
Module to abstract storing files on hard drive or in a shared system between multiple countly instances, currently based on GridFS
- Source:
Members
(static) fs
- Description:
Direct FS methods
- Source:
Direct FS methods
(static) gridfs
- Description:
Direct GridFS methods
- Source:
Direct GridFS methods
(static) type
- Description:
Currently used file storage type
- Source:
Currently used file storage type
Methods
(static) deleteFile(category, dest, optionsopt, callback)
- Description:
Delete file from shared system
- Source:
Example
countlyFs.deleteFile("test", "AGPLv3", function(err){
console.log("Finished", err);
});
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
category |
string | collection where to store data |
|||||||
dest |
string | file's destination |
|||||||
options |
object |
<optional> |
additional options for saving file Properties
|
||||||
callback |
function | function called when deleting was completed or errored, providing error object as first param |
(static) exists(category, dest, optionsopt, callback)
- Description:
Check if file exists
- Source:
Example
countlyFs.exists("test", "./CHANGELOG.md", function(err, exists){
if(exists)
console.log("File exists");
});
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
category |
string | collection where to store data for gridfs |
|||||||
dest |
string | file's destination |
|||||||
options |
object |
<optional> |
additional options for saving file Properties
|
||||||
callback |
function | function called when we have result, providing error object as first param and boolean as second to indicate if file exists |
(static) getData(category, dest, optionsopt, callback)
- Description:
Get file data
- Source:
Example
countlyFs.getData("test", "AGPLv3", function(err, data){
console.log("Retrieved", err, data);
});
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
category |
string | collection from where to read data |
|||||||
dest |
string | file's destination |
|||||||
options |
object |
<optional> |
additional options for saving file Properties
|
||||||
callback |
function | function called when retrieving file was completed or errored, providing error object as first param and filedata as second |
(static) getHandler() → {object}
- Description:
Get handler for connection to close it, for stopping separate scripts
- Source:
Example
var db = countlyFs.getHandler();
db.close();
Returns:
databse connection
- Type
- object
(static) getSize(category, dest, optionsopt, callback)
- Description:
Get file size
- Source:
Example
countlyFs.getSize("test", "AGPLv3", function(err, size){
console.log("Retrieved", err, size);
});
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
category |
string | collection from where to read data |
|||||||
dest |
string | file's destination |
|||||||
options |
object |
<optional> |
additional options for saving file Properties
|
||||||
callback |
function | function called when retrieving file size was completed or errored, providing error object as first param and file size as second |
(static) getStats(category, dest, optionsopt, callback)
- Description:
Get file stats
- Source:
Example
countlyFs.getStats("test", "AGPLv3", function(err, stats){
//similar to fs.stat object
console.log("Retrieved", err, stats);
});
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
category |
string | collection from where to read data |
|||||||
dest |
string | file's destination |
|||||||
options |
object |
<optional> |
additional options for saving file Properties
|
||||||
callback |
function | function called when retrieving file size was completed or errored, providing error object as first param and file size as second |
(static) getStream(category, dest, optionsopt, callback)
- Description:
Get stream for file
- Source:
Example
countlyFs.getStream("test", "CHANGELOG.md", function(err, stream){
var writeStream = fs.createWriteStream('./CHANGELOG.md');
stream.pipe(writeStream);
});
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
category |
string | collection from where to read data |
|||||||
dest |
string | file's destination |
|||||||
options |
object |
<optional> |
additional options for saving file Properties
|
||||||
callback |
function | function called when establishing stream was completed or errored, providing error object as first param and stream as second |
(static) rename(category, dest, source, optionsopt, callback)
- Description:
Move or Rename existing file
- Source:
Example
countlyFs.rename("test", "AGPLv3", "LICENSE.md", function(err){
console.log("Finished", err);
});
Parameters:
| Name | Type | Attributes | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
category |
string | collection where to store data |
|||||||
dest |
string | file's destination |
|||||||
source |
string | source file |
|||||||
options |
object |
<optional> |
additional options for saving file Properties
|
||||||
callback |
function | function called when renaming was completed or errored, providing error object as first param |
(static) saveData(category, dest, data, optionsopt, callback)
- Description:
Save string data in shared system
- Source:
Example
countlyFs.saveData("test", "test.text", "some\nmultiline\ntest", function(err){
console.log("Storing data finished", err);
});
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
category |
string | collection where to store data |
||||||||||||||||||||||
dest |
string | file's destination |
||||||||||||||||||||||
data |
string | data to save |
||||||||||||||||||||||
options |
object |
<optional> |
additional options for saving file Properties
|
|||||||||||||||||||||
callback |
function | function called when saving was completed or errored, providing error object as first param |
(static) saveFile(category, dest, source, optionsopt, callback)
- Description:
Save file in shared system
- Source:
Example
countlyFs.saveFile("test", "./CHANGELOG", "./CHANGELOG.md", function(err){
console.log("Storing file finished", err);
});
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
category |
string | collection where to store data |
||||||||||||||||||||||
dest |
string | file's destination |
||||||||||||||||||||||
source |
string | source file |
||||||||||||||||||||||
options |
object |
<optional> |
additional options for saving file Properties
|
|||||||||||||||||||||
callback |
function | function called when saving was completed or errored, providing error object as first param |
(static) saveStream(category, dest, readStream, optionsopt, callback)
- Description:
Save file from stream in shared system
- Source:
Example
countlyFs.saveStream("test", "AGPLv3", fs.createReadStream("AGPLv3"), function(err){
console.log("Storing stream finished", err);
});
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
category |
string | collection where to store data |
||||||||||||||||||||||
dest |
string | file's destination |
||||||||||||||||||||||
readStream |
stream | stream where to get file content |
||||||||||||||||||||||
options |
object |
<optional> |
additional options for saving file Properties
|
|||||||||||||||||||||
callback |
function | function called when saving was completed or errored, providing error object as first param |
(static) setHandler(dbCon)
- Description:
Set handler for connection
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
dbCon |
object | database connection |