Interface IUploadReservation
- All Known Implementing Classes:
UploadReservation
public interface IUploadReservation
One authorized transfer of one or more files, minted by
IFileUploadService.reserve(List, IFileUploadListener) and bound to the application session that made it.The reservation ID is opaque and loggable and is part of the upload URL. The per-file secrets are bearer credentials: they travel only in the X-iizi-upload header and are never logged; a caller that reads them through getSecret(int) must hand them only to the client the reservation was made for.
- Author:
- Christopher Mindus
Method Summary
Modifier and TypeMethodDescriptionvoidCancels one file or the whole reservation.intGets the chunk size the client must use, in bytes.List<? extends IUploadFile> getFiles()Gets the files, accepted or refused, in the order they were requested; a file's index in this list is itsIUploadFile.getFileIndex().getID()Gets the reservation ID: 16 random bytes as 32 lower-case hex characters.intGets the idle timeout in force, in seconds.intGets the maximum file count per reservation in force.intGets the maximum pause time in force, in seconds: how long the reservation may stay paused (by the App or the client) before it is cancelled with reasonmaxPause.getPath()Gets the relative upload path, ending with '/'.Gets the permitted media types in force, as configured, empty for any.Gets the reason the whole reservation was refused.longGets the remaining allowance after this reservation, i.e.getSecret(int fileIndex) Gets the per-file secret.booleanChecks if the reservation as a whole was accepted.booleanChecks if the reservation was cancelled as a whole.booleanisClosed()Checks if every file has reached a terminal state or been verified, i.e.booleanChecks if the App wants the automatic failure notice for this reservation: a cancellation only the server knows about (idle,start,maxPause) is then shown to the client as one message box listing the files.booleanisPaused()Checks if the reservation is paused as a whole: no file is receiving chunks and at least one isUploadState.PAUSED.voidPauses one file or every receiving file: the client is told to stop sending and a chunk sent anyway is refused as paused, never as a failure.voidresume(int fileIndex) Resumes one file or every file the App paused: the client is told it may send again.
Method Details
getID
String getID()Gets the reservation ID: 16 random bytes as 32 lower-case hex characters.- Returns:
- The ID.
getPath
String getPath()Gets the relative upload path, ending with '/'. The client resolves it against the origin it already uses for its WebSocket; the server never composes a scheme, host or port.- Returns:
- The path, e.g.
/iizi-upload/.
isAccepted
boolean isAccepted()Checks if the reservation as a whole was accepted. A refused reservation has no accepted files andgetRefusalReason()says why.- Returns:
- true if accepted.
getRefusalReason
String getRefusalReason()Gets the reason the whole reservation was refused.- Returns:
- The reason, or null if accepted.
getFiles
List<? extends IUploadFile> getFiles()Gets the files, accepted or refused, in the order they were requested; a file's index in this list is itsIUploadFile.getFileIndex().- Returns:
- The files, never null.
getSecret
Gets the per-file secret. Never log it.- Parameters:
fileIndex- The file index.- Returns:
- The secret as base64url without padding, or null if the file was refused.
- Throws:
IndexOutOfBoundsException- For an invalid index.
getChunkSize
int getChunkSize()Gets the chunk size the client must use, in bytes.- Returns:
- The chunk size.
getRemainingBytes
long getRemainingBytes()Gets the remaining allowance after this reservation, i.e. the most a further reservation of the same session could declare, in bytes.- Returns:
- The remaining bytes, or
Long.MAX_VALUEif unlimited.
getMaxFiles
int getMaxFiles()Gets the maximum file count per reservation in force.- Returns:
- The count.
getPermittedTypes
String getPermittedTypes()Gets the permitted media types in force, as configured, empty for any.- Returns:
- The comma-separated list.
getIdleTimeout
int getIdleTimeout()Gets the idle timeout in force, in seconds.- Returns:
- The seconds after which an idle reservation is cancelled.
getMaxPause
int getMaxPause()Gets the maximum pause time in force, in seconds: how long the reservation may stay paused (by the App or the client) before it is cancelled with reasonmaxPause. The idle timeout does not run while paused.- Returns:
- The seconds.
isNoticeEnabled
boolean isNoticeEnabled()Checks if the App wants the automatic failure notice for this reservation: a cancellation only the server knows about (idle,start,maxPause) is then shown to the client as one message box listing the files. On by default.- Returns:
- true if the notice is shown, false if the App reports failures its own way.
isClosed
boolean isClosed()Checks if every file has reached a terminal state or been verified, i.e. no further byte is expected.- Returns:
- true if closed.
isCancelled
boolean isCancelled()Checks if the reservation was cancelled as a whole.- Returns:
- true if cancelled.
isPaused
boolean isPaused()Checks if the reservation is paused as a whole: no file is receiving chunks and at least one isUploadState.PAUSED. The idle timeout is suspended and the maximum pause time runs.- Returns:
- true if paused as a whole.
pause
Pauses one file or every receiving file: the client is told to stop sending and a chunk sent anyway is refused as paused, never as a failure. The listener seesIFileUploadListener.onFilePaused(IUploadReservation, IUploadFile, String). A file that is complete, verified or terminal is left alone; a file the client has already paused is additionally held by the App.- Parameters:
fileIndex- The file index, or -1 for every file.reason- The reason, reported to the listener and the client; null or empty meanspaused.
resume
void resume(int fileIndex) Resumes one file or every file the App paused: the client is told it may send again. A file the client has also paused stays paused until the client resumes it.- Parameters:
fileIndex- The file index, or -1 for every file.
cancel
Cancels one file or the whole reservation. Cancel means cancel: the staged bytes are deleted immediately and the quota is released.- Parameters:
fileIndex- The file index, or -1 for the whole reservation.reason- The reason, recorded on the file(s) and reported to the listener.