node_modules/@adonisjs/bodyparser/src/Multipart/index.js
/**
   * Process files by going over each part of the stream. Files
   * are ignored when there are no listeners listening for them.
   *
   * @method process
   *
   * @return {Promise}
   */
Process files by going over each part of the stream. Files
are ignored when there are no listeners listening for them.

@method process

@return {Promise}
Process files by going over each part of the stream . Files are ignored when there are no listeners listening for them . @method process @return { Promise }
process () {
    if (this._processedStream) {
      return Promise.reject(GE.RuntimeException.invoke('Cannot process multipart stream twice. Make sure to disable files {autoProcess} when manually calling multipart.process', 500, 'E_CANNOT_PROCESS_STREAM'))
    }
    return new Promise((resolve, reject) => {
      this._processedStream = true
      const form = new multiparty.Form(this._multipartyOptions)
      form.on('error', reject)
      form.on('part', (part) => {
        this.onPart(part)
          .then(() => {
            part.resume()
            if (form.flushing <= 0 && this._pendingPromises.size === 0) {
              resolve()
            }
          })
          .catch((error) => form.emit('error', error))
      })
      form.on('field', (name, value) => {
        if (name && typeof (this._fieldsCallback) === 'function') {
          this._fieldsCallback(name, value)
        }
      })
      form.on('close', () => {
        if (this._pendingPromises.size === 0) {
          resolve()
        }
      })
      form.parse(this.req)
    })
  }
process ( ) { if ( this . _processedStream ) { return Promise . reject ( GE . RuntimeException . invoke ( 'Cannot process multipart stream twice. Make sure to disable files {autoProcess} when manually calling multipart.process' , 500 , 'E_CANNOT_PROCESS_STREAM' ) ) } return new Promise ( ( resolve , reject ) => { this . _processedStream = true const form = new multiparty . Form ( this . _multipartyOptions ) form . on ( 'error' , reject ) form . on ( 'part' , ( part ) => { this . onPart ( part ) . then ( ( ) => { part . resume ( ) if ( form . flushing <= 0 && this . _pendingPromises . size === 0 ) { resolve ( ) } } ) . catch ( ( error ) => form . emit ( 'error' , error ) ) } ) form . on ( 'field' , ( name , value ) => { if ( name && typeof ( this . _fieldsCallback ) === 'function' ) { this . _fieldsCallback ( name , value ) } } ) form . on ( 'close' , ( ) => { if ( this . _pendingPromises . size === 0 ) { resolve ( ) } } ) form . parse ( this . req ) } ) }
Process files by going over each part of the stream.
Process files by going over each part of the stream .