Days
Hours
Minutes
Seconds
x

Froala Editor v4.3 is hereLEARN MORE

Skip to content

Node.JS SDK Image Reference

upload (req, fileRoute, options, callback)

Method used to upload an image to the specified location on disk.

Parameters:


  • req

    In Node.JS, the uploaded image is available in the request received by your application.

    Type: Request Object

  • fileRoute

    The path of the image is relative to the root of the application.

    Type: String

  • options

    This parameter is optional. Use it to pass custom options for the image upload.

    Type: Object

  • callback

    A callback function which called when the upload method finishes, or an error occurs. Invoked with (err, data).

    Type: Function


options parameter:

  • fieldname

    The field name from the request object.

    Type: String
    Default:
    "file"
  • validation

    A Javascript Object or a function used to validate the uploaded image. The Javascript Object specifies the allowed image extensions through allowedExts and the allowed mime types through allowedMimeTypes. Invoke the function with: filePath, mimetype, and callback.

    Type: Object or Function
    Default:
    {
      'allowedExts': ['gif', 'jpeg', 'jpg', 'png', 'svg', 'blob'],
      'allowedMimeTypes': ['image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/svg+xml']
    }
    
  • resize

    An array with custom options to scale the image. Available options are the ones from Node.JS GraphicsMagick library resize. Example:

    [200, 200, "!"]

    Type: Array
    Default:
    NULL

delete (src, callback)

Method used to delete an image from disk.

Parameters:


  • src

    The image path available in the body of the request: request.body.src.

    Type: String

  • callback

    A callback function which call when the delete method finishes, or an error occurs. Invoked with (err, data).

    Type: Function

list (folderPath, thumbPath, callback)

Method used to list all images from disk.

Parameters:


  • folderPath

    The folder path from where the images are loaded is relative to the root of your application.

    Type: String

  • thumbPath

    This parameter is optional. The folder path from where the image thumbs are loaded is relative to the root of your application.

    Type: String

  • callback

    A callback function called when the list method finishes, or an error occurs. Invoked with (err, data).

    Type: Function

Do you think we can improve this article? Let us know.