How to set response filename without forcing “save as” dialog

前端 未结 2 354
独厮守ぢ
独厮守ぢ 2020-12-04 10:34

I am returning a stream in some response setting the appropriate content-type header. The behavior I\'m looking for is this:

  • If the browser is

相关标签:
2条回答
  • 2020-12-04 11:07

    I'm not sure if that's possible by default. Due to security concerns, browsers don't send all content-types they can handle, but just a few Accept-Encoding, which doesn't help a lot in your scenario.

    Maybe you can ask your user what they prefer and store that information in their profile.

    0 讨论(0)
  • 2020-12-04 11:10

    The correct way could be:

    Content-Disposition: inline; filename="myfile.txt"

    0 讨论(0)
提交回复
热议问题