File Descriptor class

Architecture tips:

  1. Physically Saltcorn stores files on local filesystem of the server, where Saltcorn runs.
  2. The path to file store is defined in db.connectObj.file_store.
  3. List of files stored in _sc_files table in Saltcorn database.
  4. Each tenant has own file list and file storage.
  5. This class provides file descriptor and basic functions to manipulate with files.

Hierarchy

  • File

Constructors

Properties

filename: string
id?: number
isDirectory: boolean
location: string
mime_sub: string
mime_super: string
min_role_read: number
s3_store: boolean
size_kb: number
uploaded_at: Date
user_id?: number

Accessors

Methods

  • Delete file

    Parameters

    • Optional unlinker: ((arg0) => Promise<void>)
        • (arg0): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns Promise<void | {
        error: string;
    }>

  • Parameters

    • Optional encoding: "utf8" | "base64" | "base64url" | "hex" | "ascii"

    Returns Promise<Buffer>

  • Move file to other folder

    Parameters

    • newFolder: string

      target folder for file

    Returns Promise<void>

  • Parameters

    • contents: string | Buffer | ArrayBuffer

    Returns Promise<void>

  • Set Min Role to read for file

    Parameters

    • min_role_read: number

      target Role for file to read

    Returns Promise<void>

  • get all directories in the root folder (tenant root dir for multi-tenant)

    Parameters

    • Optional ignoreCache: boolean

      if a cache exists, ignore it

    Returns Promise<File[]>

  • Ensure that file_store path is physically exists in file system. In reality just recursively creates full absolute path to db.connectObj.file_store.

    Parameters

    • Optional tenant_name: string

    Returns Promise<void>

  • Select list of file descriptors

    Parameters

    • Optional where: Where
    • selectopts: SelectOptions = {}

    Returns Promise<File[]>

  • Create new file

    Parameters

    • name: string
    • mimetype: string
    • contents: string | Buffer | ArrayBuffer
    • user_id: number
    • min_role_read: number = 1
    • folder: string = "/"

    Returns Promise<File>

  • Create new file

    Parameters

    • file: {
          mimetype: string;
          mv: Function;
          name: string;
          s3object?: boolean;
          size: number;
      }
      • mimetype: string
      • mv: Function
      • name: string
      • Optional s3object?: boolean
      • size: number
    • user_id: number
    • min_role_read: number = 1
    • folder: string = "/"

    Returns Promise<File>

  • Get absolute path to new file in db.connectObj.file_store.

    Parameters

    • Optional suggest: string

      path to file inside file store. If undefined that autogenerated uudv4 is used.

    • Optional renameIfExisting: boolean

    Returns string

    • path to file
  • Create new folder

    Parameters

    • name: string
    • inFolder: string = ""

    Returns Promise<undefined>

  • Parameters

    • trusted_base: string
    • Rest ...unsafe_paths: string[]

    Returns null | string

  • Parameters

    • name: string
    • absoluteFolder: string
    • user: User

    Returns Promise<void>

  • Update File descriptor

    Parameters

    • id: number

      primary key

    • row: Row

      row data

    Returns Promise<void>

    no returns

  • This is a mobile-app function, it uploads a file to the saltcorn server.

    Parameters

    • file: {
          blob: Blob;
          fileObj: any;
      }

      file to upload

      • blob: Blob
      • fileObj: any

    Returns Promise<any>

    JSON response from POST 'file/upload'

Generated using TypeDoc