Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "core/file-storage"

Index

Variables

Let sharp

sharp: any = null

Functions

createFolderIfMissing

  • createFolderIfMissing(folderPath: any): Promise<void>
  • Creates a folder. No-op if the folder exists. Does not make the folder relative to the file storage root.

    Parameters

    • folderPath: any

    Returns Promise<void>

exists

  • exists(documentPath: any): Promise<boolean>

getImageType

  • getImageType(filepath: any): Promise<any>
  • Get the type of an image file.

    Parameters

    • filepath: any

      the absolute path to a file.

    Returns Promise<any>

    one of 'jpg', 'png' or 'gif' if valid; undefined if not.

isValidPicture

  • isValidPicture(picturePath: string): Promise<boolean>
  • Parameters

    • picturePath: string

    Returns Promise<boolean>

    whather the specified path is a valid picture

read

  • read(documentPath: any): Promise<string>
  • [read description]

    Parameters

    • documentPath: any

    Returns Promise<string>

    the file contents as a string. Caller must parse JSON himself if needed.

remove

  • remove(documentPath: any): Promise<void>

resize

  • resize(sourcePath: any, targetPathWithoutExtension: any, fileExtension: any, options?: any): Promise<any>
  • Parameters

    • sourcePath: any
    • targetPathWithoutExtension: any
    • fileExtension: any
    • Default value options: any = {}

    Returns Promise<any>

savePictureToModel

  • savePictureToModel(model: any, attribute: any, fileUpload: any, deleteFile: any, targetPathWithoutExtension: any, options?: any): Promise<any>
  • Saves a file upload on a model. The picture will be resized (if needed) & moved, but model.save() won't be called. The file extension will be grabbed from the source path. If folders don't exist, they will be created. If there was a pre-exiting picture, it will be deleted.

    Parameters

    • model: any
    • attribute: any
    • fileUpload: any

      The form field to save

    • deleteFile: any

      Whether to delete the picture

    • targetPathWithoutExtension: any

      The path to the destination, relative to the uploads folder

    • Default value options: any = {}

      (Optional) allowed: maxDiagonal

    Returns Promise<any>

    result, with either "error" or "finalPath" set, or nothing if the picture was deleted

savePictureUpload

  • savePictureUpload(fileUploadOrPath: any, targetPathWithoutExtension: any, options?: any): Promise<any>
  • Saves an upload to the specified path, resizing it if needed in the process. The file extension will be grabbed from the source path. If folders don't exist, they will be created.

    throws

    if the source path is not a valid picture

    Parameters

    • fileUploadOrPath: any

      The form field to save, or the file path if this is not a form upload

    • targetPathWithoutExtension: any

      The path to the destination, relative to the uploads folder

    • Default value options: any = { maxDiagonal: 2000 }

      (Optional) allowed: maxDiagonal / maxWidth / maxHeight / fit / suffix / format). See presets: constants.PICTURE_OPTIONS_*

    Returns Promise<any>

    the URL to that path

toAbsolutePath

  • toAbsolutePath(anyPath: string): string

write

  • write(documentPath: any, data: any): Promise<void>
  • Writes data to a file

    Parameters

    • documentPath: any

      Destination file

    • data: any

      Contents to write. If a function, will be evaluated. If an object/array, will be stringified.

    Returns Promise<void>

Object literals

Const IMAGE_HEADER_MAGIC_TO_TYPE

IMAGE_HEADER_MAGIC_TO_TYPE: object

474946

474946: string = "gif"

89504e470d0a1a0a

89504e470d0a1a0a: string = "png"

ffd8ff

ffd8ff: string = "jpg"

Generated using TypeDoc