Skip to content
cbou edited this page Jan 31, 2012 · 13 revisions

List of all available routes

Routes return only json strings. Status code is 200 if no error occurs or 500 if errors occur.

If errors occur an array of errors will be inserted in the json.

Normal response is (e.g. for a post):

  {}

Response with error:

{
  error: [
    error1, error2
  ]
}

Response with data (e.g. readFile)

{
  data: 'The is the content of the file.'
}

It's also possible to have response and error:

{
  data: 'The is the content of the file.'
  error [...]
}

Rename a path

Default URI: /fs2http/rename

method: POST

Parameters:

path1: source path to rename

path2: new path

Rename a path, using fs.rename(path1, path2, [callback])


Change owner of a path

Default URI: /fs2http/chown

method: POST

Parameters:

path: The path

uid: The user id

gid: The group

Change owner of a path, using fs.chown(path, uid, gid, [callback]) It's not recursive.


Change mode of a path

Default URI: /fs2http/chmod

method: POST

Parameters:

path: The path

mode: The mode

Change mode of a path, using fs.chmod(path, mode, [callback]) It's not recursive.


Get status of a path

Default URI: /fs2http/stat

method: GET

Parameters:

path: The path

Example response:

{
  stats: 
    { 
      dev: 2114,
      ino: 48064969,
      mode: 33188,
      nlink: 1,
      uid: 85,
      gid: 100,
      rdev: 0,
      size: 527,
      blksize: 4096,
      blocks: 8,
      atime: Mon, 10 Oct 2011 23:24:11 GMT,
      mtime: Mon, 10 Oct 2011 23:24:11 GMT,
      ctime: Mon, 10 Oct 2011 23:24:11 GMT 
    }
}

Get status of a path, using fs.stat(path, [callback])


Remove a directory

Default URI: /fs2http/rmdir

method: DELETE

Parameters:

path: The path

Remove a directory, using fs.rmdir(path, [callback]) It's not recursive.


Create a directory

Default URI: /fs2http/mkdir

method: POST

Parameters:

path: The path

mode: The mode (optional, see node documentation for default)

Create a directory, using fs.mkdir(path, [mode], [callback])


Read a directory

Default URI: /fs2http/readdir

method: GET

Parameters:

path: The path

Example response:

{
  files: ['myfile', 'myfile1', 'myfile2']
}

Read a directory, using fs.readdir(path, [callback])


Change file last access and modification times of a path

Default URI: /fs2http/utimes

method: POST

Parameters:

path: The path

atime: The new file access time (in unix timestamp format)

mtime: The new file modification time (in unix timestamp format)

Change file last access and modification times of a path, using fs.utimes(path, atime, mtime, [callback])


Read a file

Default URI: /fs2http/readFile

method: GET

Parameters:

path: The path

encoding: The encoding (optional). NOTE: Without encoding, a raw buffer object is return

Example response:

{
  data: 'content of my file'
}

Read a file, using fs.readFile(path, [encoding], [callback])


Write in a file

Default URI: /fs2http/writeFile

method: GET

Parameters:

path: The path

data: The data

encoding: The encoding (optional see node documentation for default)

Write in a file, using fs.writeFile(path, data, [encoding], [callback])


Change owner of a path recursively

Default URI: /fs2http/chownRec

method: POST

Parameters:

path: The path

uid: The user id

gid: The group

Change owner of a path, file or directory, recursively.


Change mode of a path recursively

Default URI: /fs2http/chmodRec

method: POST

Parameters:

path: The path

mode: The mode

Change mode of a path, file, directory or symbolic lynk, recursively.


Remove a directory recursively

Default URI: /fs2http/rmRec

method: DELETE

Parameters:

path: The path

Remove a file, directory or link, using fs.rmdir(path, [callback])


Create a symbolic link

Default URI: /fs2http/symlink

method: POST

Parameters:

path: Path to link

link: The new link

Create a symbolic link, using fs.symlink(linkdata, path, [type], [callback])


Remove a link (file or symbolic link)

Default URI: /fs2http/unlink

method: DELETE

Parameters:

path: Path to unlink

Remove a link (file or symbolic link), using fs.unlink(path1, path2, [callback])

It's does not work for directory.


Read a link

Default URI: /fs2http/readlink

method: GET

Parameters:

path: link to read

Example response:

{
  linkString: '/path/to/file'
}

Read a link, using fs.readlink(path, [callback])


Check if a path exists

Default URI: /fs2http/exists

method: GET

Parameters:

path: path to check

Example response:

{
  exists: true
}

Check if a path exists, using path.exists(path, [callback])


Copy a file or a dir

Default URI: /fs2http/copyRec

method: POST

Parameters:

path: The path

newpath: The new path where the copy goes

Copy a path to another. It works for directory, files (not for link at the moment)