angular-filemanager-bridge
v0.1.4
Published
Node.js bridge for angular-filemanager
Downloads
2
Readme
angular-filemanager-nodejs-bridge
This project provides a backend for the fantastic angular-filemanager UI written with Node.js and Express.
CAUTION: This project is currently not mainted! If you want to take over this project or you already developed a better implementation, please send me a message and I will link to your project.
Features
Currently the following operations are (partially) implemented:
- Implement new API for click-changes branch of angular-filemanager.
- Copy
- Create folder
- Download/Preview
- Edit file
- Get content of a file
- Listing
- Remove
- Rename/Move
- Upload file
- Security: Ensure users cannot access paths they are not allowed to access (e.g. passing "../../" as path)
TODO
- Proper error handling
- Missing API functions
- Return correct file permissions
- Compress file
- Extract file
- Set permissions
Usage (standalone)
- Checkout this Git repository:
git clone https://github.com/fkoester/angular-filemanager-nodejs-bridge.git
- Install dependencies:
npm install
- run
DATA_DIR=/tmp npm start
Change DATA_DIR variable to the root folder you want angular-filemanager to operate on
- Configure angular-filemanager in your angular app:
app.config(function (fileManagerConfigProvider) {
var defaults = fileManagerConfigProvider.$get();
fileManagerConfigProvider.set({
copyUrl: '{/files}/copy', // where {/files} is the mount path of this module.
createFolderUrl: '{/files}/createFolder',
downloadFileUrl: '{/files}/download',
editUrl: '{/files}/edit',
removeUrl: '{/files}/remove',
renameUrl: '{/files}/rename',
uploadUrl: '{/files}/upload',
getContentUrl: '{/files}/getContent',
listUrl: '{/files}/list',
});
});
Using Docker
You can also run this server via Docker using the image maestroalubia/angular-filemanager-nodejs-bridge.
The easiest way to get it up running is using docker-compose, just run docker-compose up
in the project root. This exports the host's /tmp
directory. You can change this by changing the docker-compose.yml
file.
Usage (in other express application)
If you want to integrate this bridge into your own Express application you can do so by adding it as a dependency:
Install via npm
npm install --save angular-filemanager-nodejs-bridge
Import and configure the router
const express = require('express'); const filesRouter = require('angular-filemanager-nodejs-bridge').router; const routes = express.Router(); routes.use('/files', filesRouter);
Configure a custom base dir function (optional)
const pathresolver = require('angular-filemanager-nodejs-bridge').pathresolver;
pathresolver.baseDir = function(req) {
if(req.body.username = 'foo') {
return '/foo';
}
return '/bar';
};