我想创建一个速成应用程序,为用户提供下载链接。我将一个直接链接放到一个路由上,然后用户直接下载:https://myserver.com/?url=(some直接链接到文件)&type=(文件扩展名)&dlheader=(文件类型)/(文件扩展名)&title=(文件名下载)注意:直接链接来自其他服务器
发布于 2022-05-16 19:12:34
您可以获取url查询参数,并像这样通过node.js发送文件。但是您没有提供关于您的文件在服务器上的位置的信息。
app.get('/', async function(req, res) {
// take paramaters from url
const url = req.query.url;
const type= req.query.type;
const dlheader= req.query.dlheader;
const title= req.query.title;
//then send file
res.sendFile(`/your/file/path/${title}.${type}`)
});https://stackoverflow.com/questions/72264184
复制相似问题