Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • FileManager

Index

Constructors

Properties

cache: Dict<string, Dict<string, File>>
client: PteroClient
serverId: string

Methods

  • _patch(dir: string, data: any): Dict<string, File>
  • Transforms the raw file object(s) into typed objects.

    Parameters

    • dir: string
    • data: any

      The resolvable file object(s).

    Returns Dict<string, File>

    The resolved file object(s).

  • Changes the permissions on one or more files in a specified directory.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.chmod(
    './',
    [{ file: 'server.jar', mode: 0o755 }]
    )
    .catch(console.error);

    Parameters

    • dir: string

      The root path of the files.

    • files: FileChmodData[]

      The file mode descriptors.

    Returns Promise<void>

  • compress(dir: string, files: string[]): Promise<File>
  • Compresses the specified files into a zip file.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.compress(
    './'
    ['server.properties', 'server.jar', 'config.yml']
    )
    .then(console.log)
    .catch(console.error);

    Parameters

    • dir: string

      The root directory of the files.

    • files: string[]

      The files to be compressed.

    Returns Promise<File>

    The compressed files.

  • copy(path: string): Promise<void>
  • Copies the specified file in its directory.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.copy('server.properties').catch(console.error);

    Parameters

    • path: string

      The path of the file to copy.

    Returns Promise<void>

  • createFolder(path: string, name: string): Promise<void>
  • Creates a folder in a specified root folder.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.createFolder('./', 'ext').catch(console.error);

    Parameters

    • path: string

      The root path to create the directory in.

    • name: string

      The name of the directory.

    Returns Promise<void>

  • decompress(dir: string, file: string): Promise<void>
  • Decompresses the specified file in its directory.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.decompress('./ext', 'archive-2022-08-25T034234Z.tar.gz')
    .catch(console.error);

    Parameters

    • dir: string

      The root directory of the file.

    • file: string

      The file to decompress.

    Returns Promise<void>

  • delete(dir: string, files: string[]): Promise<void>
  • Deletes one or more files in the specified directory.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.delete('./', ['old-install.log'])
    .catch(console.error);

    Parameters

    • dir: string

      The root directory of the files.

    • files: string[]

      The files to delete.

    Returns Promise<void>

  • download(path: string, dest: string): Promise<void>
  • Fetches and saves a file to a specified path on the system.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.download('./config.yml', '/mc/config.yml')
    .catch(console.error);

    Parameters

    • path: string

      The file path.

    • dest: string

      The file path to save the file to.

    Returns Promise<void>

  • fetch(dir?: string): Promise<Dict<string, File>>
  • Fetches the files/directories in a specified direcory (defaults to root).

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.fetch().then(console.log).catch(console.error);

    Parameters

    • dir: string = '/'

    Returns Promise<Dict<string, File>>

    The fetched files.

  • getContents(path: string): Promise<string>
  • Fetches the contents of a specified file. The content is always returned as a string by default, regardless of file type.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.getContents('./install.log')
    .then(console.log)
    .catch(console.error);

    Parameters

    • path: string

      The file path.

    Returns Promise<string>

    The file contents.

  • getDownloadURL(path: string): Promise<string>
  • Fetches the download URL for a specified file.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.getDownloadURL('./config.yml')
    .then(console.log)
    .catch(console.error);

    Parameters

    • path: string

      The file path.

    Returns Promise<string>

    The download URL.

  • getUploadURL(dir?: string): Promise<string>
  • Fetches the upload URL for a specified directory (defaults to root).

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.getUploadURL('./plugins')
    .then(console.log)
    .catch(console.error);

    Parameters

    • dir: string = '/'

    Returns Promise<string>

    The upload URL.

  • rename(path: string, files: { from: string; to: string }[]): Promise<void>
  • Renames one or more files in a specified directory.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.rename(
    './',
    [
    { from: 'install.log', to: 'old-install.log' },
    { from: '_config.yml', to: 'new-config.yml' }
    ]
    )
    .catch(console.error);

    Parameters

    • path: string

      The root path of the files.

    • files: { from: string; to: string }[]

      The file rename descriptors.

    Returns Promise<void>

  • write(path: string, content: any): Promise<void>
  • Writes the content to a specified file.

    example
    const server = await client.servers.fetch('aea005b6');
    await server.files.write(
    './config.yml',
    'listeners:\n- host: 0.0.0.0:6203\n query_port: 6203'
    )
    .catch(console.error);

    Parameters

    • path: string

      The file path.

    • content: any

      The content to write.

    Returns Promise<void>

Generated using TypeDoc