Skip to content

Node.JS SDK File Reference

upload (req, fileRoute, options, callback)

Method used to upload file to the specified location on disk.

Parameters:


  • req

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

    Type: Request Object

  • fileRoute

    The path of the file is relative to the root of your application.

    Type: String

  • options

    This parameter is optional. It can be used to pass custom options for the file upload.

    Type: Object

  • callback

    A callback function which is called when the upload method has finished, 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. The function should be invoked 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']
    }
    

delete (src, callback)

Method used to delete a file from disk.

Parameters:


  • src

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

    Type: String

  • callback

    A callback function which is called when the delete method has finished, or an error occurs. Invoked with (err, data).

    Type: Function

File: 2104