Sign inSign up

hasnat/rest-ftp

By hasnat

•Updated almost 5 years ago

Adds RESTful HTTP wrapper to FTP

Image
0

1.2K

hasnat/rest-ftp repository overview

⁠rest-ftp

Adds RESTful HTTP wrapper to FTP

Based on ftpfs⁠ and rest-fs⁠ (currently via forks)


Docker: rest-ftp⁠

docker pull hasnat/rest-ftp

docker-compose example⁠

⁠docker-compose up

ENV Variables:

FTP_USER: admin         -- default blank
FTP_PASS: admin         -- default blank
FTP_HOST: ftp-server    -- default 127.0.0.1
FTP_PORT: 21            -- default 21
FTP_SECURE: false       -- default false

⁠API: from rest-fs⁠

⁠GET /path/to/dir/

list contents of directory

optional
?recursive = list recursively default false

returns: list of full file or folder paths (trailing slash tells if dir)

res.body = [ { "fullDirPath" }, ... ]
⁠File Stats

?stats = Return file stats for the directory instead of file listing.

res.body = {
  dev: 16777220,
  mode: 16877,
  nlink: 31,
  uid: 501,
  gid: 20,
  rdev: 0,
  blksize: 4096,
  ino: 604862,
  size: 1054,
  blocks: 0,
  atime: Thu Mar 05 2015 11:38:47 GMT-0800 (PST),
  mtime: Thu Mar 05 2015 10:52:41 GMT-0800 (PST),
  ctime: Thu Mar 05 2015 10:52:41 GMT-0800 (PST)
}

⁠GET /path/to/file

returns contents of file
if dir, redirect to dir path

optional
?encoding = default utf8

returns: res.body = { "file content" }

⁠File Stats

?stats = Return file stats for the file instead of file's contents.

res.body = {
  dev: 16777220,
  mode: 16877,
  nlink: 31,
  uid: 501,
  gid: 20,
  rdev: 0,
  blksize: 4096,
  ino: 604862,
  size: 1054,
  blocks: 0,
  atime: Thu Mar 05 2015 11:38:47 GMT-0800 (PST),
  mtime: Thu Mar 05 2015 10:52:41 GMT-0800 (PST),
  ctime: Thu Mar 05 2015 10:52:41 GMT-0800 (PST)
}

⁠POST /path/to/file/or/dir

creates or overwrites file
creates dir if it does not exist.
renames or moves file if newPath exists

optional
body.newpath = if exist, move/rename file to this location.
body.clobber = if true will overwrite dest files (default false)
body.mkdirp = if true will create path to new location (default false)
body.mode = permissions of file (defaults: file 438(0666) dir 511(0777))
body.encoding = default utf8

optional for stream
query.clobber = overwrite if exist query.mode = permissions of file (defaults: file 438(0666) dir 511(0777))
query.encoding = default utf8

returns: modified resource. (trailing slash tells if dir)

req.body = { "fullFileOrDirPath" }

⁠PUT /path/to/file

creates file

optional
body.mode = permissions of file (438 default 0666 octal)
body.encoding = default utf8

returns: modified resource (trailing slash tells if dir)

req.body = { "fullFilePath" }

⁠DEL /path/to/dir/

deletes folder
if file returns error

returns:

req.body = {}

⁠DEL /path/to/file

deletes file
if folder returns error

returns:

req.body = {}

Tag summary

Content type

Image

Digest

Size

333.5 MB

Last updated

almost 5 years ago

docker pull hasnat/rest-ftp