#Pass file from response

1 messages · Page 1 of 1 (latest)

worn zealot
#

I call a third-party API in my application and I need to return the response the same way it's received to from my API. How do I do that?

This is the response object from the third-party:

Cache-Control: private, must-revalidate, max-age=0, s-maxage=0
Transfer-Encoding: chunked
Content-Type: application/pdf
Expires: Wed, 29 May 2024 18:54:09 GMT
Last-Modified: Wed, 29 May 2024 18:54:09 GMT
ETag: "2105551196"
Vary: Cookie,Accept,Accept-Encoding
Server: Microsoft-IIS/10.0
Content-Disposition: attachment; filename=ACH_insert_update_12-29-23.pdf
X-Powered-By: ASP.NET
Date: Wed, 29 May 2024 18:54:09 GMT```

And the body is obviously the file. I've tried...
```TS
return response
  .contentType(file.contentType)
  .setHeader('Content-Disposition', file.contentDisposition)
  .send(file.buffer)

using @Res({ passthrough: true }) response: Response with import { Response } from 'express'

worn zealot
#

The issue I think I'm having is with the file encoding I'm receiving.

#

when I tried just using writeFile(path/to/dir, response.data) the PDF file is created, but there is a bunch of metadata missing. What I'm seeing from exiftool is Linearized : No Warning : Invalid secondary xref table