How to download a pdf at adonis 5

1.9k views Asked by At

Hi Everybody im using adonis 5 in my backend and im saving files at public directory i can to see and to download images but this does not working in pdf file, this working at adonis js 4.1 using adonis drive but drive its not in Adonis 5 there is a some way for to see or to download pdf ad adonis 5?

Thanks for the answers!

1

There are 1 answers

0
Amir Hosein Salimi On

Case 1:

If you just want to send back a file URL to let your users decide whether to download it or not, you can simply put that file in your public folder and send them the link: e.g. http://{{YOUR_HOST}}/filename.ext

This will work just fine until you have the static server configured properly.

Case 2:

If you want to forcibly make users download your files - rather than just visiting them in the browser - you may want to use the attachment helper which automatically sets proper response headers for downloading files.

ctx.response.attachment('public/filename.ext')