1

I'm using an express server to proxy a file to download from amazon s3. How do I either preserve the filename in the header or set the filename info in the headers so that when a user downloads the filename it doesn't just say s3.jpeg but instead correctly says 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);
  });
4

1 回答 1

4

Ok, seems easy enough

res.setHeader('Content-disposition', 'attachment; filename=test.jpg');

in coffeescript

app.get "/s3", (req, res) ->

    res.setHeader('Content-disposition', 'attachment; filename=test.jpg');

    client.download(
        container:'test'
        remote:'test.jpg'
    ).pipe res
于 2013-03-30T20:18:30.357 回答