OpenVeo server API for plugins

API Docs for: 7.0.0
Show:

fileSystem

Defined in: lib/fileSystem.js:3
Module: fileSystem

Summary

Defines functions to interact with the file system as an extension to the Node.js filesystem module.

// Load module "fileSystem"
var fsApi = require('@openveo/api').fileSystem;

Item Index

Methods

Properties

Methods

copy

Syntax

copy

(
  • sourcePath
  • destinationSourcePath
  • callback
)
static async

Summary

Copies a file or a directory.

Parameters:

  • sourcePath String

    Path of the source to copy

  • destinationSourcePath String

    Final path of the source

  • callback Function

    The function to call when done

    • Error The error if an error occurred, null otherwise

copyFile

Syntax

copyFile

(
  • sourceFilePath
  • destinationFilePath
  • callback
)
private static async

Summary

Copies a file.

If directory does not exist it will be automatically created.

Parameters:

  • sourceFilePath String

    Path of the file

  • destinationFilePath String

    Final path of the file

  • callback Function

    The function to call when done

    • Error The error if an error occurred, null otherwise

extract

Syntax

extract

(
  • filePath
  • destinationPath
  • [callback]
)
static async

Summary

Extracts a tar file to the given directory.

Parameters:

  • filePath String

    Path of the file to extract

  • destinationPath String

    Path of the directory where to extract files

  • [callback] Function optional

    The function to call when done

    • Error The error if an error occurred, null otherwise

getConfDir

Syntax

getConfDir

() String static

Summary

Gets OpenVeo configuration directory path.

OpenVeo configuration is stored in user home directory.

Returns:

String:

OpenVeo configuration directory path

getFileTypeFromBuffer

Syntax

getFileTypeFromBuffer

(
  • file
)
String static

Summary

Gets file type.

Parameters:

  • file Buffer

    At least the first 300 bytes of the file

Returns:

String:

The file type

getJSONFileContent

Syntax

getJSONFileContent

(
  • filePath
  • callback
)
static async

Summary

Gets a JSON file content.

This will verify that the file exists first.

Parameters:

  • filePath String

    The path of the file to read

  • callback Function

    The function to call when done

    • Error The error if an error occurred, null otherwise
    • String The file content or null if an error occurred

mkdir

Syntax

mkdir

(
  • directoryPath
  • [callback]
)
static async

Summary

Creates a directory.

If parent directory does not exist, it will be automatically created. If directory already exists, it won't do anything.

Parameters:

  • directoryPath String

    The directory system path to create

  • [callback] Function optional

    The function to call when done

    • Error The error if an error occurred, null otherwise

mkdirRecursive

Syntax

mkdirRecursive

(
  • directoryPath
  • callback
)
private static async

Summary

Creates a directory recursively and asynchronously.

If parent directories do not exist, they will be automatically created.

Parameters:

  • directoryPath String

    The directory system path to create

  • callback Function

    The function to call when done

    • Error The error if an error occurred, null otherwise

readdir

Syntax

readdir

(
  • directoryPath
  • callback
)
static async

Summary

Gets the content of a directory recursively and asynchronously.

Parameters:

  • directoryPath String

    Path of the directory

  • callback Function

    The function to call when done

    • Error The error if an error occurred, null otherwise
    • Array The list of resources insides the directory

readdirRecursive

Syntax

readdirRecursive

(
  • directoryPath
  • callback
)
private static async

Summary

Reads a directory content recursively and asynchronously.

It is assumed that the directory exists.

Parameters:

  • directoryPath String

    Path of the directory

  • callback Function

    The function to call when done

    • Error The error if an error occurred, null otherwise
    • Array The list of fs.Stats corresponding to resources inside the directory (files and directories)

readFile

Syntax

readFile

(
  • filePath
  • [offset]
  • [length]
  • callback
)
static async

Summary

Gets part of a file as bytes.

Parameters:

  • filePath String

    Path of the file

  • [offset] Number optional

    Specify where to begin reading from in the file

  • [length] Number optional

    The number of bytes ro read

  • callback Function

    The function to call when done

    • Error The error if an error occurred, null otherwise
    • Buffer The buffer containing read bytes

rm

Syntax

rm

(
  • resourcePath
  • [callback]
)
static async

Summary

Removes a resource.

If resource is a directory, the whole directory is removed.

Parameters:

  • resourcePath String

    Path of the resource to remove

  • [callback] Function optional

    The function to call when done

    • Error The error if an error occurred, null otherwise

rmdir

Defined in lib/fileSystem.js:591

Deprecated: Use rm instead

Syntax

rmdir

(
  • directoryPath
  • [callback]
)
deprecated static async

Summary

Removes a directory and all its content recursively and asynchronously.

Parameters:

  • directoryPath String

    Path of the directory to remove

  • [callback] Function optional

    The function to call when done

    • Error The error if an error occurred, null otherwise

rmdirRecursive

Syntax

rmdirRecursive

(
  • directoryPath
  • callback
)
private static async

Summary

Removes a directory and all its content recursively and asynchronously.

It is assumed that the directory exists.

Parameters:

  • directoryPath String

    Path of the directory to remove

  • callback Function

    The function to call when done

    • Error The error if an error occurred, null otherwise

Properties

FILE_TYPES

Syntax

FILE_TYPES

Object final

Summary

The list of file types.

FILE_TYPES

Syntax

FILE_TYPES

Object final

Summary

The list of file types.