Interface UploadContent
- All Superinterfaces:
Serializable
UploadValidator.validateComplete(UploadEvent, UploadContent) so that
whole-content checks (for example antivirus scanning) can inspect the data
before it is delivered to the success callback.
The content is only valid for the duration of the validateComplete
call and must not be retained: for a file-backed upload the underlying file
may be deleted immediately after the call (for example when the upload is
rejected), and any stream handed out is closed by
the framework once the call returns.
- See Also:
-
Method Details
-
getInputStream
Opens a new stream over the received content.Each call returns an independent stream positioned at the start. The framework closes any stream returned here once the enclosing
validateCompletecall returns, so a validator must read within that call and must not retain the stream. WhenasPath()is present, prefer it for libraries that scan by file path.- Returns:
- a fresh input stream over the content
- Throws:
IOException- if the stream cannot be opened
-
size
long size()Returns the size of the received content in bytes.- Returns:
- the content size in bytes
-
asPath
Returns the path of the file backing this content, if the upload was stored to a file.Present for file-based upload handlers (
FileUploadHandler/TemporaryFileUploadHandler) and empty for in-memory uploads. The path refers to the file produced by the handler'sFileFactory; it may be deleted right aftervalidateCompletereturns if the upload is rejected.Do not hand this path to an asynchronous or background process: read or scan it synchronously within the
validateCompletecall, since the file may be gone once the call returns.- Returns:
- the backing file path, or empty if the content is not file-backed
-