Package nzilbb.labbcat.server.api.elicit
Class Upload
- java.lang.Object
-
- nzilbb.labbcat.server.api.APIRequestHandler
-
- nzilbb.labbcat.server.api.elicit.Upload
-
public class Upload extends APIRequestHandler
/api/elicit/upload : Handler for adding an elicited transcript file with associated media/document files.- POST
- This is the only supported method.
- Request Body - A multi-part encoded request with the following
parameters:
- transcript_type
- The transcript type for the new transcript.
- corpus
- The corpus to add the transcript to.
- episode
- The elicitation episode the transcript belongs to.
- transcript
- Transcript file to upload, which must be a plain-text file with a file name
ending in
.txt
. (transcript
is nominally the parameter to use, but any .txt file parameter will be taken to be the transcript, regardless of the name of the parameter.) - media
- Recording associated with the transcript, if any. If specified, this
must be an
audio/wav
file with a file name ending in.wav
. (media
is nominally the parameter to use, but any .wav file parameter will be taken to be the media file, regardless of the name of the parameter.) - doc
- Document associated with the transcript, if any. If specified, this
must be an
application/pdf
file with a file name ending in.pdf
. (doc
is nominally the parameter to use, but any .pdf file parameter will be taken to be the document file, regardless of the name of the parameter.)
- Response Body - a JSON-encoded reponse of the following structure:
{ "title":"Elicited upload", "version":"20260428.1901", "code":0, "errors":[], "messages":[], "model":{} }Themessages
anderrors
arrays may contain one or more messages for the client. - Response Status
- 200 : The upload was nominally successful (but should be confirmed with a call the the verify endpoint.
- 400 : The upload request was invalid, e.g. no transcript was received.
- 415 : Files of unsupported media types were received.
- Request Body - A multi-part encoded request with the following
parameters:
- 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
-
-
Constructor Summary
Constructors Constructor Description Upload()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.json.JsonObjectpost(RequestParameters requestParameters, Consumer<Integer> httpStatus, Function<nzilbb.ag.Graph,String> layerGenerator)The POST method for the servlet.StringvalidateWav(File wav)Checks the given file actually appears to be a WAV file.-
Methods inherited from class nzilbb.labbcat.server.api.APIRequestHandler
getContext, GetSystemAttribute, init, writeResponse
-
-
-
-
Method Detail
-
post
public javax.json.JsonObject post(RequestParameters requestParameters, Consumer<Integer> httpStatus, Function<nzilbb.ag.Graph,String> layerGenerator)
The POST method for the servlet.- Parameters:
requestParameters- Request parameter map.httpStatus- Receives the response status code, in case of error.layerGenerator- A function that will start a layer generation thread for the given transcript, and return the thread ID.- Returns:
- JSON-encoded object representing the response
-
validateWav
public String validateWav(File wav) throws IOException, FileNotFoundException
Checks the given file actually appears to be a WAV file.- Parameters:
wav- The file to validate.- Returns:
- An error if validation fails, null if the WAV file appears to be ok.
- Throws:
IOException- If the file could not be read.FileNotFoundException- If the file doesn't exist.
-
-