Strapi v3 not returning pdfs

System Information
  • Strapi Version: v3
  • Operating System: mac dev system
  • Database: defualt
  • Node Version: ^6.0.0
  • NPM Version: 14.18.3
  • Yarn Version: yarn 1.22.17

Hi there,
I have an endpoint which returns a pdf, either directly from an s3 bucket or after encoding. If I pass the s3 bucket response directly to the ctx.request.body then the pdf opens in the browser without issue. If however, I save the file to the local hard drive to be processed I cant then get the pdf to be served to the browser. When attempted (with either the original file or the processed version) I get a 404 response back.
Im not that familiar with Strapi and with this issue I am definitely struggling…


Looking at the logs in the terminal, the problem appears to be that strapi is sending its response back before the endpoint has finished processing. So, How do I stop it sending the response until after the process has finished?

Have you modified any of the code for uploading? Maybe just missing an await on the method that loads it?

Ended up re-writing it as a promise as the “await” wasn’t waiting properly.