我正在使用express服务器代理从amazon s3下载的文件。如何在标题中保留文件名,或者在标题中设置文件名信息,以便当用户下载文件名时,它不只是说s3.jpeg,而是正确地说test.jpg?
app.get("/s3", function(req, res) {
var client;
client = require('pkgcloud').storage.createClient({
provider: "amazon",
key: "test",
keyId: "test"
});
return client.download({
container: 'test',
remote: 'test.jpg'
}).pipe(res);
});发布于 2013-03-31 04:18:30
好的,看起来很简单
res.setHeader('Content-disposition',‘附件;filename=test.jpg');
在coffeescript中
app.get "/s3", (req, res) ->
res.setHeader('Content-disposition', 'attachment; filename=test.jpg');
client.download(
container:'test'
remote:'test.jpg'
).pipe reshttps://stackoverflow.com/questions/15723007
复制相似问题