【问题标题】:Postman - File name from "Send and Download"邮递员 - 来自“发送和下载”的文件名
【发布时间】:2016-10-19 06:26:20
【问题描述】:

在 Postman 中,如何控制使用“发送和下载”选项下载的文件的名称?它始终是“响应”,但我希望它是发送过来的文件的实际名称。

【问题讨论】:

  • 运气好,想要做同样的事情吗?
  • 我记得看过关于创作者如何“修复”这个问题的帖子,但没有任何实际描述如何做到这一点
  • 寻找相同的

标签: postman


【解决方案1】:

响应不是你的错。这个问题正在积极处理中。目前,它不会尊重您在响应中的标题。

您可以在此处跟踪此问题: https://github.com/postmanlabs/postman-app-support/issues/2082

【讨论】:

    【解决方案2】:

    我刚刚在 Google 中查找了这个,似乎他们还没有在 Postman 中添加这个选项。

    这是 Github 问题,最后一次更新是 4 天前。

    https://github.com/postmanlabs/postman-app-support/issues/2082

    希望这对浏览此页面的人有所帮助。

    【讨论】:

      【解决方案3】:

      Postman 已解决此问题;通过修改服务器中的“Content-Disposition”响应标头,您可以控制下载文件的名称。

      示例导轨代码:

      def show
        if request.headers['Accept'] == 'application/pdf'
          send_data @document.read_file(:pdf)
          # response.headers['Content-Disposition] == "attachment" # send_data sets this initially
          response.headers['Content-Disposition'] += '; filename="document.pdf"'
        else
          respond_with @document, params
        end
      end
      

      【讨论】:

        猜你喜欢
        • 2019-01-20
        • 2019-09-07
        • 2017-07-08
        • 2017-11-28
        • 1970-01-01
        • 2019-02-24
        • 2019-11-12
        • 2015-03-21
        • 2021-11-19
        相关资源
        最近更新 更多