title: Using multipart/form-data in Nestjs
body: <p>I have a requirement of uploading a pdf file to the a third-party API to do that what we are using a controller and then sending its buffer to the endpoint in multipart/form-data but It's not working. What am i doing wrong??</p>
  <p>I have my controller defined like</p>
  <pre class="lang-js prettyprint-override"><code>    @Post('/upload')
      @UseInterceptors(FileInterceptor('file'))
      async uploadDocument(@UploadedFile() file: Express.Multer.File){
          await this.httpRequestService.uploadDocument(file)
          return [
              Translation.translate('Create_Success_Message', {
                  Entity: 'File'
              }),
              {
                  file
              }
          ]
      }
  </code></pre>
  <p>This controller calls a service called <code>uploadDocument</code> which looks like:</p>
  <pre class="lang-js prettyprint-override"><code>async uploadDocument(file){
          try{
          const formData = new FormData()
          formData.append('file', file)
          const response = await this.httpService.post(`urlWhereItHits`,
          formData, 
          {   
              headers:{ 
                  &quot;X-AppSecretToken&quot;:&quot;appsecrettoken&quot;,
                  &quot;X-AgreementGrantToken&quot;:&quot;agreementgranttoken&quot;,
                  'Content-Type' : 'multipart/form-data'
              },
              
          }).toPromise();
          }
          catch(error){
              console.log(error)
          }
  }
  </code></pre>
  <p>Now i don't understand what's happening wrong here.
  I get error saying<br />
  <code>TypeError: source.on is not a function at Function.DelayedStream.create (C:\Users\Tushar\Squire-backend\node_modules\delayed-stream\lib\delayed_stream.js:33:10)</code></p>