{"_id":"@anzuev/studcloud.fileinterface","_rev":"6-a43e8d9ac89c6f4db9b0a60337318d3e","name":"@anzuev/studcloud.fileinterface","description":"File interface for StudCloud project","dist-tags":{"latest":"1.1.2"},"versions":{"1.0.0":{"name":"@anzuev/studcloud.fileinterface","version":"1.0.0","description":"File interface for StudCloud project","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["studcloud","files","filesinterface"],"author":{"name":"AnZuev"},"license":"ISC","dependencies":{"@anzuev/studcloud.datamodels":"^0.2.4","mongoose":"^4.5.0","nconf":"^0.8.4","path":"^0.12.7","q":"^1.4.1","winston":"^2.2.0"},"gitHead":"dd79601c678f7708fb0fa1c4109665d89530bb13","_id":"@anzuev/studcloud.fileinterface@1.0.0","_shasum":"226bdf0133cefb901bdd6d7bacd74009be46c938","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.4.1","_npmUser":{"name":"anzuev","email":"anzuev@istudentapp.ru"},"dist":{"shasum":"226bdf0133cefb901bdd6d7bacd74009be46c938","tarball":"https://registry.npmjs.org/@anzuev/studcloud.fileinterface/-/studcloud.fileinterface-1.0.0.tgz","integrity":"sha512-we1WuhSySUG5kCLUM+U4yDzIqbekCN4SLJ/oe0UmYbhdWe2HqU8m2jazUstx17IrJKqKHoqdzrfZBwe2uAJ9xg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGsnUTH/6CCpjwnfPQQvut+da/yza+PJRCKqbnQAcQY3AiAOVhY8dcDszniGSHH6iKl1kCUuz35988FyNO7AYOp9/A=="}]},"maintainers":[{"name":"anzuev","email":"anzuev@istudentapp.ru"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/studcloud.fileinterface-1.0.0.tgz_1465921328026_0.9255634120199829"}},"1.1.0":{"name":"@anzuev/studcloud.fileinterface","version":"1.1.0","description":"File interface for StudCloud project","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["studcloud","files","filesinterface"],"author":{"name":"AnZuev"},"license":"ISC","dependencies":{"@anzuev/studcloud.datamodels":"^0.2.4","mongoose":"^4.5.0","nconf":"^0.8.4","path":"^0.12.7","q":"^1.4.1","winston":"^2.2.0"},"gitHead":"ecf1b25d19f93d8b38499451402e13549c932af9","_id":"@anzuev/studcloud.fileinterface@1.1.0","_shasum":"0a474fe494964da6d7b718e164853531bf78194a","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.4.1","_npmUser":{"name":"anzuev","email":"anzuev@istudentapp.ru"},"dist":{"shasum":"0a474fe494964da6d7b718e164853531bf78194a","tarball":"https://registry.npmjs.org/@anzuev/studcloud.fileinterface/-/studcloud.fileinterface-1.1.0.tgz","integrity":"sha512-WntjAlf71aFuXLw3WwP7c3ctL/co2xDYKRA5lhmYdjZzhPvRHmPhCONYXwiRGJuE+jGphEy0mZLJDplOeJBDZw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD/tw2Py6rAvBsJGlBNBGPMjlHxNS4q8oS2+2Zww9Vt2AIhAIFVmb7wQb6BYaw8qAcW0VBptr+cWkNLwm1WOGOUQVAg"}]},"maintainers":[{"name":"anzuev","email":"anzuev@istudentapp.ru"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/studcloud.fileinterface-1.1.0.tgz_1465927353192_0.4126393760088831"}},"1.1.1":{"name":"@anzuev/studcloud.fileinterface","version":"1.1.1","description":"File interface for StudCloud project","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["studcloud","files","filesinterface"],"repository":{"type":"git","url":"git+https://github.com/AnZuev/StudCloud.FileInterface.git"},"author":{"name":"AnZuev"},"license":"ISC","dependencies":{"@anzuev/studcloud.datamodels":"^0.2.4","mongoose":"^4.5.0","nconf":"^0.8.4","path":"^0.12.7","q":"^1.4.1","winston":"^2.2.0"},"gitHead":"a1258d4109ec2b1b1c0c7f7d01018853007678e3","bugs":{"url":"https://github.com/AnZuev/StudCloud.FileInterface/issues"},"homepage":"https://github.com/AnZuev/StudCloud.FileInterface#readme","_id":"@anzuev/studcloud.fileinterface@1.1.1","_shasum":"778ba647b06495fafceb6d4f32459165889e3bdc","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.4.1","_npmUser":{"name":"anzuev","email":"anzuev@istudentapp.ru"},"dist":{"shasum":"778ba647b06495fafceb6d4f32459165889e3bdc","tarball":"https://registry.npmjs.org/@anzuev/studcloud.fileinterface/-/studcloud.fileinterface-1.1.1.tgz","integrity":"sha512-RYOb0SBjMWst6MIDlnqoPzPQIth1yvoeA6R1OeTfSX3ofAssDbQX/FFhUyyrxDS8g0/Rg0/pxKpD+SIijHJVkQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCra75EdohD0dMXwrOwPTP2aIlOuJeyhlVIbV6YnQWuEQIhAMk55SgXVq3TJxaxI1abtMi/99GTSfizf0x+NqycvXrr"}]},"maintainers":[{"name":"anzuev","email":"anzuev@istudentapp.ru"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/studcloud.fileinterface-1.1.1.tgz_1465927449328_0.6090584576595575"}},"1.1.2":{"name":"@anzuev/studcloud.fileinterface","version":"1.1.2","description":"File interface for StudCloud project","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["studcloud","files","filesinterface"],"repository":{"type":"git","url":"git+https://github.com/AnZuev/StudCloud.FileInterface.git"},"author":{"name":"AnZuev"},"license":"ISC","dependencies":{"@anzuev/studcloud.datamodels":"^0.2.4","mongoose":"^4.5.0","nconf":"^0.8.4","path":"^0.12.7","q":"^1.4.1","winston":"^2.2.0"},"gitHead":"a114db3b476dc912213bf0af213ead2cdff6a1ca","bugs":{"url":"https://github.com/AnZuev/StudCloud.FileInterface/issues"},"homepage":"https://github.com/AnZuev/StudCloud.FileInterface#readme","_id":"@anzuev/studcloud.fileinterface@1.1.2","_shasum":"6d03034bd85a9ad41133c38938f3768bda4b2bd3","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.4.1","_npmUser":{"name":"anzuev","email":"anzuev@istudentapp.ru"},"dist":{"shasum":"6d03034bd85a9ad41133c38938f3768bda4b2bd3","tarball":"https://registry.npmjs.org/@anzuev/studcloud.fileinterface/-/studcloud.fileinterface-1.1.2.tgz","integrity":"sha512-2dhTRDvugTqwWxJiTaqeEbiEXpjsfCSbOuz4YaRu+IbfCd6PYn2KrOhTWXhkyU8Wmdpr2EIf9lTHiDG+N4EhPw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGfsCTDVq5SGs+26Rypq6lrCWfrkFYvlDdmMQ0MY6FgpAiAMZE62VUa+us0zyFEuDN+L1YV0xs8OZ1wo8+M6dEQfDg=="}]},"maintainers":[{"name":"anzuev","email":"anzuev@istudentapp.ru"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/studcloud.fileinterface-1.1.2.tgz_1465930539294_0.05034505017101765"}}},"readme":"# StudCloud.FileInterface  \n\n## Install using npm  \nnpm i @anzuev/studcloud.fileinterface\n\n## Description\nМодуль, который представляет собой интерфейс для взаимодействия с коллекцией files.\nМодуль позволяет настраивать базу данных, с которой на данный момент нужно работать.\nДля этого необходимо передать объект mongooseConnection\n\n##API description\n\n### Configure\n```javascript\n  //configure.js file\n  \n  \n  /*\n    require FileInterface Object\n  */\n  let FileInterface = require('@anzuev/studcloud.fileinterface');\n  \n  /*\n    create an instance of FileInterface Object\n  */\n  let fileInterface = new FileInterface();\n  \n  /* \n    create mongooseConnection here or require it from somewhere else\n  */\n  let connection = mongoose.createConnection(/* settings*/);\n  \n  /*\n    !!! It is important to configure FileInterface object(connect this module to specific db)\n        If you forget to do that you are going to get an DbError 'No connection was configured for FileInterface module'\n  */\n  fileInterface.setConnection(connection);\n\n  /*\n    export fileInterface(using connection to specific db);\n  */\n  module.exports = fileInterface.get();\n```\n\n### Usage\n```javascript\n  // index.js file\n  \n  let fileInterface = require(/*path to configure.js file*/\"./configure.js\");\n  \n  let promise1 = fileInterface.add(.....);\n  let promise2 = fileInterface.getFileById(...);\n  \n  // work with promises\n  promise1.then(function(file){\n    \n  }).catch(function(error){\n  \n  });\n  \n  //or work with es6 generators and Q.async\n  \n  Q.async(function*(){\n    let file = yield promise1;\n    let file2 = yield promise2;\n    ...\n  })().done();\n  \n  .....\n  \n```\n\n\n##API description\n\n### FileInterface\n- **setConnection(connection)**  \n  Description: *set connection that FileInterface object will use*  \n  Input: *mongoose connection. (mongoose.connect or mongoose.createConnection)*  \n  Output: *void*  \n  \n- **get()**  \n  Description: *get model(collection 'files' in db passed using method setConnection)*  \n  Input: *void*  \n  Output:  \n  - *file model(mongoose.model)*\n  - *Throw DbError(@anzuev/studcloud.errors) if model hasn't been configured yet*\n\n### File model(fileInterface.get());\n - **add(url, publicAccess, accessItem, path, title, uploader)**  \n   Description: *try to add file to files collection*  \n  Input:  \n     - *url - String url файла*\n     - *publicAccess - Boolean is file public?*\n     - *accessItem - Object only if publicAccess == false*\n        - type - string accessType(group or convId)\n        - value - value of convId(for group it's not used)\n     - *path - String Path to file*\n     - *title - String title to display*\n     - *uploader - String userId who upload this file*  \n       \n  Output: \n     - *promise to save file and return file if everything ok*\n     - *throws DbError if can't save file*  \n       \n - **getFileById(id)**  \n   Description: *try to get file from files collection by id*  \n     \n   Input:  \n     - *id - String id файла*  \n       \n   Output:\n     - *promise to return file*\n        - resolve promise with file if everything ok\n        - reject promise if DbError happened\n     - *throws DbError if file doesn't exist*  \n     \n - **formatWithPath()**\n   Description: *return formatted object*  \n   Input:  \n     - *void*  \n       \n   Output:\n     - *object*\n        - id - String file._id\n        - uploader - String file.uploader\n        - path - String file.path\n        - access - Object file.access\n            - publicAccess - Boolean isPublic\n            - cType - String type (convId or group). Exists only if publicAccess==false\n            - value - String value. Exists only if cType == group     \n              \n - **formatWithoutPath()**\n   Description: *return formatted object*  \n   Input:  \n     - *void*  \n       \n   Output:\n     - *object*\n        - id - String file._id\n        - uploader - String file.uploader\n        - access - Object file.access\n            - publicAccess - Boolean isPublic\n            - cType - String type (convId or group). Exists only if publicAccess==false\n            - value - String value. Exists only if cType == group \n              \n - **setFileUsed(save)**\n   Description: *set file used*  \n   Input:  \n     - *save - Boolean. If true - file will be saved immediately*   \n       \n   Output:\n     - *promise to save file if save == true*\n        - file if everything ok\n        - DbError if error happened\n     - *true if save != true*  \n       \n         \n - **setFileUnused(save)**\n   Description: *set file unused*  \n   Input:  \n     - *save - Boolean. If true - file will be saved immediately*    \n         \n   Output:\n     - *promise to save file if save == true*\n        - file if everything ok\n        - DbError if error happened\n     - *true if save != true*    \n     \n - **saveFile()**\n   Description: *save file*  \n   Input:  \n     - *void*   \n         \n   Output:\n     - *promise to save file*\n        - file if everything ok\n        - DbError if error happened\n  \n   \n","maintainers":[{"name":"anzuev","email":"anzuev@istudentapp.ru"}],"time":{"modified":"2022-06-12T14:43:24.807Z","created":"2016-06-14T16:22:11.086Z","1.0.0":"2016-06-14T16:22:11.086Z","1.1.0":"2016-06-14T18:02:35.480Z","1.1.1":"2016-06-14T18:04:12.308Z","1.1.2":"2016-06-14T18:55:42.674Z"},"keywords":["studcloud","files","filesinterface"],"author":{"name":"AnZuev"},"license":"ISC","readmeFilename":"README.md","homepage":"https://github.com/AnZuev/StudCloud.FileInterface#readme","repository":{"type":"git","url":"git+https://github.com/AnZuev/StudCloud.FileInterface.git"},"bugs":{"url":"https://github.com/AnZuev/StudCloud.FileInterface/issues"}}