Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3809

Filedownload name encoding

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.5.1
    • 8.5.0
    • Components
    • Security Level: Jimmy
    • None
    • ZK 8.5.1 R1

      Steps to Reproduce

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

      Current Result

      will download the file as test.txt omitting #test

      Expected Result

      file downloaded as test#test.txt

      Debug Info

      in DesktopImpl.getDownloadMediaURI special characters inside the file name like "#?&" need to be %-encoded to avoid file name truncation
      see: https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters

      Workaround

      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

      -------------
      Alternative is to override the getDownloadMediaURI method by extending DesktopImpl and configure a custom webapp factory to return instances of the custom DesktopImpl class

            rudyhuang rudyhuang
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 4 hours Original Estimate - 4 hours
                4h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours
                5h