Class FileService

java.lang.Object
com.nt.udc.filebrowser.service.FileService

public class FileService extends Object
  • Constructor Details

    • FileService

      public FileService()
  • Method Details

    • isWhitelisted

      public static boolean isWhitelisted(Path realPath)
      Determines whether the provided real path is under one of the configured allowed prefixes.
      Parameters:
      realPath - absolute/normalized path
      Returns:
      true if allowed, false otherwise
    • listFiles

      public static FileListResponse listFiles(FileListRequest request) throws FileBrowserException
      Returns a list of files for the given request parameters.
      Parameters:
      request - request containing directory path, filters, and sorting options
      Returns:
      file list response with requested details
      Throws:
      FileBrowserException - if the directory cannot be accessed or processed
    • formatDateTime

      public static String formatDateTime(long millis)
      Converts an epoch-millis timestamp to a human-readable "yyyy-MM-dd HH:mm:ss" string using the default time zone.
      Parameters:
      millis - epoch milliseconds
      Returns:
      formatted timestamp string
    • getDefaultFilebrowserPath

      public static String getDefaultFilebrowserPath() throws FileBrowserException
      Returns a configured default path for the filebrowser.
      Returns:
      default path string
      Throws:
      FileBrowserException - if default path is not configured or invalid