download(file, filename, options, callback) {

    let name = filename
    let opts = typeof options === 'object' ? options : {}
    let fn = typeof callback === 'function' ? callback : undefined

    // Add optional parameter support for callback
    if (typeof filename === 'function') {
      name = undefined
      fn = filename
    } else if (typeof options === 'function') {
      fn = options
    }

    // Add optional parameter support for options
    if (typeof filename === 'object') {
      name = undefined
      opts = filename
    }

    // Add the Content-Disposition header
    this.attachment(name ? name : (typeof file === 'string' ? path.basename(file) : null))

    // Send the file
    this.sendFile(file, opts, fn)

  }
// Convenience method combining attachment() and sendFile()
Convenience method combining attachment() and sendFile()
Convenience method combining attachment () and sendFile ()
download(file, filename, options, callback) {
    let name = filename
    let opts = typeof options === 'object' ? options : {}
    let fn = typeof callback === 'function' ? callback : undefined
    if (typeof filename === 'function') {
      name = undefined
      fn = filename
    } else if (typeof options === 'function') {
      fn = options
    }
    if (typeof filename === 'object') {
      name = undefined
      opts = filename
    }
    this.attachment(name ? name : (typeof file === 'string' ? path.basename(file) : null))
    this.sendFile(file, opts, fn)
  }
download ( file , filename , options , callback ) { let name = filename let opts = typeof options === 'object' ? options : { } let fn = typeof callback === 'function' ? callback : undefined if ( typeof filename === 'function' ) { name = undefined fn = filename } else if ( typeof options === 'function' ) { fn = options } if ( typeof filename === 'object' ) { name = undefined opts = filename } this . attachment ( name ? name : ( typeof file === 'string' ? path . basename ( file ) : null ) ) this . sendFile ( file , opts , fn ) }
Convenience method combining attachment() and sendFile()
Convenience method combining attachment () and sendFile ()
// Add optional parameter support for callback // Add optional parameter support for options // Add the Content-Disposition header // Send the file