Search code examples
zk

ZK8 Filedownload.save Cut Filenames


I use "Filedownload.save" to download files with Zk, but i have a problem.

Zk cut my filenames in some characters, for example, if the linema is "FISH#CHIPS.pdf", the file dowload as "FISH.pdf"

Anyone knows how to solve it?

UPDATE:

I have follow the instructions, and i finally see that the server response this JSON:

{"rs":[["download",["/myApp/zkau/view/z_aq5/dwnmed-3/son/FISH#CHIPS.pdf"]]],"rid":9}

And i am lost now, what do Zk with this JSON on the cliente side?


Solution

  • The official ZK-Bug is tracked as ZK-3809

    A server side workaround is the following:

    split download code such as ...

    Filedownload.save("test content", "text/plain", "test#test.txt");
    

    ... into ...

    AMedia media = new AMedia("test#test.txt", "txt", "text/plain", "test content");
    Clients.response(new AuDownload((DeferredValue) () -> 
        Executions.getCurrent().getDesktop().getDownloadMediaURI(
            media, "test#test.txt").replace("#", "%23")));
    

    ... allowing to encode special chars as needed.


    UPDATE: ZK-3809 has been fixed and will be included in ZK version 8.5.1