Class UploadedFile
java.lang.Object
com.iizix.server.upload.UploadedFile
- All Implemented Interfaces:
IUploadedFile, IUploadFile
Constructor Summary
ConstructorsConstructorDescriptionUploadedFile(UploadFileEntry entry, UploadStagingStore store, FileUploadRegistry registry) Constructor.Method Summary
Modifier and TypeMethodDescriptionlongdecompressTo(Path target) Streams the decompressed content to a target file.voiddelete()Deletes the staged file now: the state becomesUploadState.CONSUMEDand the quota is released.longGets the compressed (on-the-wire) bytes acknowledged so far.longGets the size of the staged file as stored, i.e.Gets the compression the transfer uses, as confirmed by the reservation.longGets the uncompressed size the client declared.Gets the media type the client declared, lower case, empty if none.getFile()Gets the staged file as stored on disk: the raw bytes as received, compressed if the transfer used gzip.intGets the file index inside its reservation,0..N-1.getGroup()Gets the group name the client placed the file in.Opens the content, transparently decompressed: a caller reads the original bytes whatever compression the transfer used.longGets the client's last-modified time.Gets the original file name as the client sent it.longGets the uncompressed bytes acknowledged so far, for progress.Gets the reservation the file belongs to.longgetSize()Gets the uncompressed size as measured during verification.getState()Gets the current state.Gets the media type verified from the file's own bytes, when the sniffer knows the type.take()Takes ownership of the raw staged file: the state becomesUploadState.CONSUMED, the quota is released, no sweep will ever touch the file again, and what happens next is the caller's business (move it, delete it, leave it).toString()Outputs to string, without the name.
Constructor Details
UploadedFile
Constructor.- Parameters:
entry- The verified entry.store- The store.registry- The registry.
Method Details
getFileIndex
public int getFileIndex()Description copied from interface:IUploadFileGets the file index inside its reservation,0..N-1. It is part of the upload URL.- Specified by:
getFileIndexin interfaceIUploadFile- Returns:
- The file index.
getReservation
Description copied from interface:IUploadFileGets the reservation the file belongs to.- Specified by:
getReservationin interfaceIUploadFile- Returns:
- The reservation.
getOriginalName
Description copied from interface:IUploadFileGets the original file name as the client sent it. Metadata only: never a path.- Specified by:
getOriginalNamein interfaceIUploadFile- Returns:
- The name.
getDeclaredType
Description copied from interface:IUploadFileGets the media type the client declared, lower case, empty if none.- Specified by:
getDeclaredTypein interfaceIUploadFile- Returns:
- The declared type.
getDeclaredSize
public long getDeclaredSize()Description copied from interface:IUploadFileGets the uncompressed size the client declared.- Specified by:
getDeclaredSizein interfaceIUploadFile- Returns:
- The declared size in bytes.
getLastModified
public long getLastModified()Description copied from interface:IUploadFileGets the client's last-modified time.- Specified by:
getLastModifiedin interfaceIUploadFile- Returns:
- Milliseconds since the epoch, 0 if unknown.
getGroup
Description copied from interface:IUploadFileGets the group name the client placed the file in.- Specified by:
getGroupin interfaceIUploadFile- Returns:
- The group, empty if none.
getCompression
Description copied from interface:IUploadFileGets the compression the transfer uses, as confirmed by the reservation.- Specified by:
getCompressionin interfaceIUploadFile- Returns:
UploadFileRequest.COMPRESSION_NONEorUploadFileRequest.COMPRESSION_GZIP.
getState
Description copied from interface:IUploadFileGets the current state.- Specified by:
getStatein interfaceIUploadFile- Returns:
- The state.
getReason
Description copied from interface:IUploadFile- Specified by:
getReasonin interfaceIUploadFile- Returns:
- The reason, or null while none applies.
getPlainBytesReceived
public long getPlainBytesReceived()Description copied from interface:IUploadFileGets the uncompressed bytes acknowledged so far, for progress.- Specified by:
getPlainBytesReceivedin interfaceIUploadFile- Returns:
- The plain high-water mark.
getBytesReceived
public long getBytesReceived()Description copied from interface:IUploadFileGets the compressed (on-the-wire) bytes acknowledged so far.- Specified by:
getBytesReceivedin interfaceIUploadFile- Returns:
- The compressed high-water mark.
getVerifiedType
Description copied from interface:IUploadedFileGets the media type verified from the file's own bytes, when the sniffer knows the type.- Specified by:
getVerifiedTypein interfaceIUploadedFile- Returns:
- The verified type in lower case, or empty if the bytes were not sniffable and the declared type stands.
getSize
public long getSize()Description copied from interface:IUploadedFileGets the uncompressed size as measured during verification. It equals the declared size, because a mismatch fails verification.- Specified by:
getSizein interfaceIUploadedFile- Returns:
- The size in bytes.
getCompressedSize
public long getCompressedSize()Description copied from interface:IUploadedFileGets the size of the staged file as stored, i.e. compressed if the transfer used gzip.- Specified by:
getCompressedSizein interfaceIUploadedFile- Returns:
- The compressed size in bytes.
getInputStream
Description copied from interface:IUploadedFileOpens the content, transparently decompressed: a caller reads the original bytes whatever compression the transfer used. Each call opens a new stream; the caller closes it.- Specified by:
getInputStreamin interfaceIUploadedFile- Returns:
- The stream of original bytes.
- Throws:
IOException- For file errors.
getFile
Description copied from interface:IUploadedFileGets the staged file as stored on disk: the raw bytes as received, compressed if the transfer used gzip. The caller must neither delete nor move it; useIUploadedFile.take()for that.- Specified by:
getFilein interfaceIUploadedFile- Returns:
- The raw file.
decompressTo
Description copied from interface:IUploadedFileStreams the decompressed content to a target file.- Specified by:
decompressToin interfaceIUploadedFile- Parameters:
target- The target path; an existing file is replaced.- Returns:
- The number of bytes written.
- Throws:
IOException- For file errors.
take
Description copied from interface:IUploadedFileTakes ownership of the raw staged file: the state becomesUploadState.CONSUMED, the quota is released, no sweep will ever touch the file again, and what happens next is the caller's business (move it, delete it, leave it). The sidecar stays until the reservation is swept.- Specified by:
takein interfaceIUploadedFile- Returns:
- The raw file, compressed if the transfer used gzip.
delete
public void delete()Description copied from interface:IUploadedFileDeletes the staged file now: the state becomesUploadState.CONSUMEDand the quota is released.- Specified by:
deletein interfaceIUploadedFile
toString