Created
July 31, 2019 21:55
-
-
Save dahngeek/f6ddb480d0d975a3e0372b408fad1e7b to your computer and use it in GitHub Desktop.
Redireccionar forzando a descargar archivo externo de terceros con express y request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
const express = require('express'); | |
// .. | |
app.get('/pdf', (req, res) => { | |
// ... | |
request(urldescarga).on("response", remoteRes => { | |
// You can add/remove/modify headers here | |
remoteRes.headers["content-disposition"] = "attachment; filename=archivodescargado.pdf"; | |
}).pipe(res); | |
// ... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment