Skip to content
Yannick Croissant edited this page Aug 16, 2013 · 5 revisions
  • list: List the folder's content.
  • share: Generate a public link for a file/folder.
  • unshare: Delete the public link of a file/folder.
  • upload: Upload a file on the NAS.

fileStation.list

List a folder

Parameters

Parameter Mandatory Default value Description
action list Action to perform. Possible values: list.
additional Additional informations to retrieve, concatenated by ,. Possibles values: real_path, size, owner, time, perm, type and mount_point_type.
filetype all Filetype filter. Possible values: dir, file and all
pattern Pattern for file filtering (wildcards allowed)
folder_path /home Absolute path of the folder to list.
limit 1000 Maximum number of files to return.
offset 0 Offset where to start the listing.
sort_by name Field used to order the files. Possible values: name, size, type, user, mtime, crtime, atime, privilege_str and group.
sort_direction ASC Set to ASC for an ascending order or to DESC for a descending one

Example

var Synology = require('synology');

var syno = new Synology();

syno.fileStation.list({
  folder_path: '/web',
  additional: 'real_path,size',
  pattern: '*module*'
}, function(err, data) {
  if (err) throw err;
  console.log(data);
});

Results

{
    "data": {
        "files": [
            {
                "additional": {
                    "real_path": "/volume1/web/node_modules",
                    "size": "4096"
                },
                "isdir": true,
                "name": "node_modules",
                "path": "/web/node_modules"
            },
            {
                "additional": {
                    "real_path": "/volume1/web/module.js",
                    "size": "14251"
                },
                "isdir": false,
                "name": "module.js",
                "path": "/web/module.js"
            }
        ],
        "offset": 0,
        "total": 2
    },
    "success": true
}

fileStation.share

Create a shareable link for a file or a directory

Parameters

Parameter Mandatory Default value Description
path Y File or directory to share.

Example

var Synology = require('synology');

var syno = new Synology();

syno.fileStation.share({
  path: '/home/foo/bar.txt'
}, function(err, data) {
  if (err) throw err;
  console.log(data);
});

Results

{
    "data": {
        "links": [{
            "error": 0,
            "id": "hLjd88BO",
            "path": "/home/foo/bar.txt",
            "qrcode": "iVBORw0KGgoAA..."
        }]
    },
    "success": true
}

fileStation.unshare

Delete a shareable link for a file or a directory

Parameters

Parameter Mandatory Default value Description
id Y ID of the file (as returned by Synology.fileStation.share).

Example

var Synology = require('synology');

var syno = new Synology();

syno.fileStation.share({
  id: 'hLjd88BO'
}, function(err, data) {
  if (err) throw err;
  console.log(data);
});

Results

{
    "success": true
}

fileStation.upload

Upload a file

Parameters

Parameter Mandatory Default value Description
file Y File to upload (Stream).
overwrite false Overwrite the file if it already exists.
create_parents true Automatically create the parents directories if needed.
dest_folder_path /home Destination folder

Example

var Synology = require('synology');

var syno = new Synology();

syno.fileStation.upload({
  file: fs.createReadStream(path.join(__dirname, 'bar.txt')),
  dest_folder_path: '/home/foo'
}, function(err, data) {
  if (err) throw err;
  console.log(data);
});

Results

{
    "success": true
}