Documentation
    Preparing search index...

    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.
    Index

    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

    • Parameters

      • Optionalencoding: "utf8" | "base64" | "base64url" | "hex" | "ascii"

      Returns Promise<Buffer<ArrayBufferLike>>

    • Parameters

      • contents: string | ArrayBuffer | Buffer<ArrayBufferLike>

      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

      • OptionalignoreCache: boolean

        if a cache exists, ignore it

      Returns Promise<export=[]>

    • 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

      • Optionaltenant_name: string

      Returns Promise<void>

    • Create new file

      Parameters

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

      Returns Promise<export=>

    • Create new file

      Parameters

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

      Returns Promise<export=>

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

      Parameters

      • Optionalsuggest: string

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

      • OptionalrenameIfExisting: boolean

      Returns string

      • path to file
    • Parameters

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

      Returns null | string

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

      Parameters

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

        file to upload

      Returns Promise<any>

      JSON response from POST 'file/upload'