Package nzilbb.labbcat.server.content
Class Files
- java.lang.Object
-
- nzilbb.labbcat.server.api.APIRequestHandler
-
- nzilbb.labbcat.server.content.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
-
-
Field Summary
-
Fields inherited from class nzilbb.labbcat.server.api.APIRequestHandler
SC_BAD_REQUEST, SC_CONFLICT, SC_CREATED, SC_FORBIDDEN, SC_INTERNAL_SERVER_ERROR, SC_METHOD_NOT_ALLOWED, SC_NOT_FOUND, SC_OK, SC_UNAUTHORIZED, SC_UNPROCESSABLE_CONTENT, SC_UNSUPPORTED_MEDIA_TYPE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconvert(File ffmpegDir, nzilbb.ag.MediaFile from, nzilbb.ag.MediaFile to)Converts from the given file to the given file.voidget(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 thefrom
request parameter if not, and if all ok, forwards the request to thedefault
servlets for serving content, handling partial content requests, etc.-
Methods inherited from class nzilbb.labbcat.server.api.APIRequestHandler
getContext, GetSystemAttribute, init, writeResponse
-
-
-
-
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 thefrom
request parameter if not, and if all ok, forwards the request to thedefault
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:
IOExceptionMediaExceptionxsnzilbb.media.MediaException
-
-