file-service
file-service
is a nodejs service based from express and route file-service provides for abcdesktop :
upload
filedownload
filedownload directory
( with zip features )delete
filedelete
directory
file-service is used by oc.filer and oc.cupsd images.
Features
sample
create a dummy.txt sample file
echo "Yet another test file" > ~/dummy.txt
start file-service in background
DISABLE_REMOTEIP_FILTERING=true yarn start 2>file-service.error > file-service.log &
query dummy.txt sample file with curl
curl http://localhost:29783/filer?file=~/dummy.txt
you get
Yet another test file
query /etc/passwd file with curl
curl http://localhost:29783/filer?file=/etc/passwd
you get
{"code":400,"data":"Path Server Error"}
API
The API documentation is avalable in file https://github.com/abcdesktopio/file-service/file-service.md
method | feature |
---|---|
GET | GET file |
POST | POST file |
DELETE | DELETE file |
GET POST DELETE features
Each main features can de disable by env vars.
var name | feature |
---|---|
SENDFILE | Allow http get |
ACCEPTFILE | Allow http put |
ACCEPTLISTFILE | Allow http list file (use json format) |
ACCEPTDELETEFILE | Allow http delete |
To disable a feature, set env var to false
export ACCEPTDELETEFILE=false
yarn start
To enable a feature, set env var to true
.
Be default all features are enabled.
export ACCEPTDELETEFILE=true
yarn start
tcp port
The defautl tcp port for this http service is 29783
process.env.FILE_SERVICE_TCP_PORT || 29783
filtering
By default each http request must come from the nginx reverse proxy source ip addr. To disable ip source filter set the DISABLE_REMOTEIP_FILTERING
to true
export DISABLE_REMOTEIP_FILTERING=true
All requested files must be located inside the user home directory. The root direcotry is equal to the user's home directory.
rootdir = process.env.HOME
run
to install
yarn install
This command installs file service modules.
to start file-service
DISABLE_REMOTEIP_FILTERING=true yarn start
This command start a file service and listen to the default tcp port.
to run test
CONTAINER_IP=127.0.0.1 yarn test
This command run test file one a running file service.
to make docs
yarn docs
This command create a file-service.md
file.