Class Files


  • public class Files
    extends APIRequestHandler
    Provides checked access to media files under the "files" directory.

    Only GET is supported. If the request path specifies a media or transcript file, the handler checks the user has access to that media.

    If the file doesn't exist, and the from request parameters specifies the name of an existing file from which the requested file could be generated, then generation is attempted on the fly.

    Author:
    Robert Fromont robert@fromont.net.nz
    • Constructor Detail

      • Files

        public Files​(File files)
        Constructor
        Parameters:
        files - The real path of the webapp's "files" directory.
    • Method Detail

      • get

        public void get​(String pathInfo,
                        RequestParameters parameters,
                        Function<String,​File> realPath,
                        Consumer<String> fileName,
                        Consumer<String> contentType,
                        Consumer<Integer> httpStatus,
                        Consumer<String> forward)
        GET handler: checks whether the given is accessible by the current users, whether file exists, can be generated from the file specified by the from request parameter if not, and if all ok, forwards the request to the default servlets for serving content, handling partial content requests, etc.
        Parameters:
        pathInfo - The URL path.
        parameters - Request parameter map.
        realPath - Function for translating an absolute URL path into a File.
        fileName - Receives the filename for specification in the response headers.
        contentType - Receives the content type for specification in the response headers.
        httpStatus - Receives the response status code, in case of error.
        forward - Receives a servlet name for the request to be forwarded to.
      • convert

        public void convert​(File ffmpegDir,
                            nzilbb.ag.MediaFile from,
                            nzilbb.ag.MediaFile to)
                     throws IOException,
                            nzilbb.media.MediaException
        Converts from the given file to the given file.
        Parameters:
        ffmpegDir - Directory where ffmpeg is installed.
        from - The the existing media file.
        to - The desired medi file.
        Throws:
        IOException
        MediaExceptionxs
        nzilbb.media.MediaException