Class FileServingHelper


  • public class FileServingHelper
    extends Object
    Static methods to help when serving uploaded files.
    • Method Detail

      • getBytestreamAliasUrl

        public static String getBytestreamAliasUrl​(String uri,
                                                   String filename,
                                                   javax.servlet.ServletContext ctx)

        Combine the URI and the filename to produce a relative URL for the file (relative to the context of the webapp). The filename will be URLEncoded as needed.

        This should involve stripping the default namespace from the front of the URL, replacing it with the file prefix, and adding the filename to the end.

        Returns:
        • the translated URL, if the URI was in the default namespace,
        • the original URI, if it wasn't in the default namespace,
        • null, if the original URI or the filename was null.
      • getBytestreamUri

        public static String getBytestreamUri​(String path,
                                              javax.servlet.ServletContext ctx)

        Take a relative URL (relative to the context of the webapp) and produce the URI for the file bytestream.

        This should involve removing the filename from the end of the URL, and replacing the file prefix with the default namespace.

        Returns:
        the URI, or null if the URL couldn't be translated.