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

Filedownload name encoding

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 8.5.0
    • Fix Version/s: 8.5.1
    • Component/s: Components
    • Security Level: Jimmy
    • Labels:
      None
    • gh.sprint.customfield.default.name:
      ZK 8.5.1 R1

      Description

      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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

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