Safari doesn't download the file with name correctly

Viewed 910

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. This works fine in Chrome but in Safari doesn't. Safari changes the name of file for something in the path URL.

E.g: the url is localhost:8080/app/documents/771 so this file is renamed to 771

Safari 14

Screenshot of 'show downloads' in Safari

Chrome

Screenshot of 'downloads' in Chrome

Code

<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>

I saw that HTML5 has a download attribute so I tried to force it.

Code

<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>

And even with this change the file wasn't with right name. But now the name is "documents" (part of my url). What's wrong in Safari and how can I fix it?

Environment

  • Primefaces 6.2

  • JSF 2

1 Answers
Related