Javascript Outlook Online如何下载附件?

Javascript Outlook Online如何下载附件?,javascript,html,reactjs,http,browser,Javascript,Html,Reactjs,Http,Browser,我试图了解从电子邮件下载多个附件时,Office365 Outlook Online中的“全部下载”按钮是如何工作的 按钮为“按钮”类型。它似乎不是表单的一部分。它有一些“点击”事件监听器(显然是使用React),但我无法理解这些监听器是否会导致下载触发 <button type="button" class="ms-Button ms-Button--action ms-Button--command _36CbeMUul160_BaOc004Od _25PDIRwPTbbCvgI4w

我试图了解从电子邮件下载多个附件时,Office365 Outlook Online中的“全部下载”按钮是如何工作的

按钮为“按钮”类型。它似乎不是表单的一部分。它有一些“点击”事件监听器(显然是使用React),但我无法理解这些监听器是否会导致下载触发

<button type="button" class="ms-Button ms-Button--action ms-Button--command _36CbeMUul160_BaOc004Od _25PDIRwPTbbCvgI4wMWgWF root-133" data-is-focusable="true">
  <span class="ms-Button-flexContainer flexContainer-78" data-automationid="splitbuttonprimary">
    <span class="ms-Button-textContainer textContainer-79">
      <span class="ms-Button-label label-49" id="id__875">Download all</span>
    </span>
  </span>
</button>
答复:

HTTP/1.1 200 OK
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/zip; authoritative=true;
Content-Encoding: gzip
Expires: Mon, 20 Jan 2020 02:34:12 +0000
Vary: Accept-Encoding
Server: Microsoft-IIS/10.0
request-id: ...
X-CalculatedFETarget: MAXPR0101CU002.internal.outlook.com
X-BackEndHttpStatus: 200
X-FEProxyInfo: MAXPR0101CA0031.INDPRD01.PROD.OUTLOOK.COM
X-CalculatedBETarget: MAXPR01MB2735.INDPRD01.PROD.OUTLOOK.COM
X-BackEndHttpStatus: 200
X-RUM-Validated: 1
X-MailboxGuid: ...
X-Content-Type-Options: nosniff
X-BeSku: WCS5
x-ms-appId: ...
X-OWA-Version: 15.20.2644.27
X-OWA-OWSVersion: V2018_01_18
X-OWA-MinimumSupportedOWSVersion: V2_6
X-Frame-Options: SAMEORIGIN
X-OWA-HttpHandler: true
Content-Disposition: attachment; filename*=UTF-8''subject.zip
X-BackEnd-Begin: 2020-01-21T02:34:12.321
X-BackEnd-End: 2020-01-21T02:34:12.349
X-DiagInfo: MAXPR01MB2735
X-BEServer: MAXPR01MB2735
X-UA-Compatible: IE=EmulateIE7
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Proxy-RoutingCorrectness: 1
X-Proxy-BackendServerStatus: 200
X-FEServer: MAXPR0101CA0031
X-FEServer: BYAPR03CA0003
Date: Tue, 21 Jan 2020 02:34:11 GMT
我无法说出触发此请求的机制:页面导航、XmlHttpRequest、Fetch?。。是什么让浏览器将其视为附件?我试图在Fiddler中截取此响应,并将响应标题更改为

Content-Type: text/html
Content-Disposition: inline
Content-Length: 5

Hello

但浏览器仍将响应作为文件下载,而不是内联呈现。为什么会这样?

这是因为响应中提供了文件类型。这是一个ZIP文件,因此它告诉浏览器将其视为ZIP文件,并应将其下载以供进一步工作。

这是由动态添加的带有下载属性的锚定标记引起的:

<a href="foo.zip" download>Download All</a>

如果内容处置的文件名与下载文件不同,则 标题优先。(如果内容配置:内联,Firefox 更喜欢标题,而Chrome更喜欢下载。)


我不认为这是基于反应。我已经更改了内容类型、内容处置头和负载,但浏览器仍将其视为下载。
<a href="foo.zip" download>Download All</a>