Safari 无法正确下载同名文件

Safari doesn't download the file with name correctly

I've a file called "Screen Shot 2552018-09-10 at 08.17.168792378923879423789324789234789234789023478943829009872438723487990724490237842378947289379802323478923478974283923487943287937428978932478324789873924789324879034278978923478923478923470897890432879 (1).png" and my code is using command link to get it.这在 Chrome 中工作正常,但在 Safari 中则不然。 Safari 更改路径 URL.

中某些内容的文件名

例如:url 是 localhost:8080/app/documents/771 所以这个文件重命名为 771

野生动物园 14

Chrome

代码

<h:commandLink value="#{document.fileName}" ajax="false" immediate="true"
 onclick="PrimeFaces.monitorDownload(PF('blockUIWV').show(), PF('blockUIWV').hide()); _paq.push(['trackEvent', 'Documents', 'Download document,'Download']);">
 <p:fileDownload value="#{bean.downloadDocument(document.myDocument)}" />
</h:commandLink>

看到HTML5有下载属性,就强行下载了

代码

<h:commandLink value="#{document.filename}" ajax="false" immediate="true"
 pt:download="#{document.filename}
 onclick="PrimeFaces.monitorDownload(PF('blockUIWV').show(), PF('blockUIWV').hide()); _paq.push(['trackEvent', 'Documents', 'Download document,'Download']);">
 <p:fileDownload value="#{bean.downloadDocument(document.myDocument)}" />
</h:commandLink>

即使进行了此更改,文件的名称也不正确。但现在的名字是“文件”(我的url的一部分)。 Safari 有什么问题,我该如何解决?

环境

所以经过研究我认为你应该向 Apple 报告这个问题。

见PF票:https://github.com/primefaces/primefaces/issues/6327

此文件名在 Chrome、Firefox、MS Edge 中运行良好。它只在 Safari 中不起作用。

在 PF 9.0 中,我们添加了一项新功能 AJAX 文件下载它确实有效 https://github.com/primefaces/primefaces/issues/5978 并且 Safari 会正确下载文件名。