简体   繁体   中英

Change the name and extension of a static file served with node

So I have some static files stored in a uploads folder running in my node.js application, but their name and extension (all of them are PDFs) were replaced by a mysql CHAR(32) string reference in DB.

I need to serve them with a comprehensible name (autogenerated in server) and it's original extension back. Any hints?

You can accomplish this with HTTP headers.

Content-disposition: attachment; filename=Example.pdf
Content-type: application/pdf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM