Interface FileUpload
- All Superinterfaces:
ByteBufHolder, Comparable<InterfaceHttpData>, HttpData, InterfaceHttpData, ReferenceCounted
- All Known Implementing Classes:
DiskFileUpload, MemoryFileUpload, MixedFileUpload
FileUpload interface that could be in memory, on temporary file or any other implementations.
Most methods are inspired from java.io.File API.
-
Nested Class Summary
Nested classes/interfaces inherited from interface InterfaceHttpData
InterfaceHttpData.HttpDataType -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a deep copy of thisByteBufHolder.Duplicates thisByteBufHolder.Returns the Content-Transfer-EncodingReturns the content type passed by the browser or null if not defined.Returns the original filename in the client's filesystem, as provided by the browser (or other client software).Returns a newByteBufHolderwhich contains the specifiedcontent.retain()Increases the reference count by1.retain(int increment) Increases the reference count by the specifiedincrement.Duplicates thisByteBufHolder.voidsetContentTransferEncoding(String contentTransferEncoding) Set the Content-Transfer-Encoding type from String as 7bit, 8bit or binaryvoidsetContentType(String contentType) Set the Content Type passed by the browser if definedvoidsetFilename(String filename) Set the original filename.touch()Records the current access location of this object for debugging purposes.Records the current access location of this object with an additional arbitrary information for debugging purposes.Methods inherited from interface ByteBufHolder
contentMethods inherited from interface Comparable
compareToMethods inherited from interface HttpData
addContent, checkSize, definedLength, delete, get, getByteBuf, getCharset, getChunk, getFile, getMaxSize, getString, getString, isCompleted, isInMemory, length, renameTo, setCharset, setContent, setContent, setContent, setMaxSizeModifier and TypeMethodDescriptionvoidaddContent(ByteBuf buffer, boolean last) Add the content from the ChannelBuffervoidcheckSize(long newSize) Check if the new size is not reaching the max limit allowed.longReturns the defined length of the HttpData.voiddelete()Deletes the underlying storage for a file item, including deleting any associated temporary disk file.byte[]get()Returns the contents of the file item as an array of bytes.
Note: this method will allocate a lot of memory, if the data is currently stored on the file system.Returns the content of the file item as a ByteBuf.
Note: this method will allocate a lot of memory, if the data is currently stored on the file system.Returns the Charset passed by the browser or null if not defined.getChunk(int length) Returns a ChannelBuffer for the content from the current position with at most length read bytes, increasing the current position of the Bytes read.getFile()longReturns the maxSize for this HttpData.Returns the contents of the file item as a String, using the default character encoding.Returns the contents of the file item as a String, using the specified charset.booleanbooleanProvides a hint as to whether or not the file contents will be read from memory.longlength()Returns the size in byte of the InterfaceHttpDatabooleanA convenience getMethod to write an uploaded item to disk.voidsetCharset(Charset charset) Set the Charset passed by the browser if definedvoidsetContent(ByteBuf buffer) Set the content from the ChannelBuffer (erase any previous data)voidsetContent(File file) Set the content from the file (erase any previous data)voidsetContent(InputStream inputStream) Set the content from the inputStream (erase any previous data)voidsetMaxSize(long maxSize) Set the maxSize for this HttpData.Methods inherited from interface InterfaceHttpData
getHttpDataType, getNameMethods inherited from interface ReferenceCounted
refCnt, release, releaseModifier and TypeMethodDescriptionintrefCnt()Returns the reference count of this object.booleanrelease()Decreases the reference count by1and deallocates this object if the reference count reaches at0.booleanrelease(int decrement) Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.
-
Method Details
-
getFilename
String getFilename()Returns the original filename in the client's filesystem, as provided by the browser (or other client software).- Returns:
- the original filename
-
setFilename
Set the original filename.Note: This method validates that the filename is safe for including in an HTTP request, and will throw an exception if that's not the case.
-
setContentType
Set the Content Type passed by the browser if defined- Parameters:
contentType- Content Type to set - must be not null
-
getContentType
String getContentType()Returns the content type passed by the browser or null if not defined.- Returns:
- the content type passed by the browser or null if not defined.
-
setContentTransferEncoding
Set the Content-Transfer-Encoding type from String as 7bit, 8bit or binary -
getContentTransferEncoding
String getContentTransferEncoding()Returns the Content-Transfer-Encoding- Returns:
- the Content-Transfer-Encoding
-
copy
FileUpload copy()Description copied from interface:ByteBufHolderCreates a deep copy of thisByteBufHolder.- Specified by:
copyin interfaceByteBufHolder- Specified by:
copyin interfaceHttpData
-
duplicate
FileUpload duplicate()Description copied from interface:ByteBufHolderDuplicates thisByteBufHolder. Be aware that this will not automatically callByteBufHolder.retain().- Specified by:
duplicatein interfaceByteBufHolder- Specified by:
duplicatein interfaceHttpData
-
retainedDuplicate
FileUpload retainedDuplicate()Description copied from interface:ByteBufHolderDuplicates thisByteBufHolder. This method returns a retained duplicate unlikeByteBufHolder.duplicate().- Specified by:
retainedDuplicatein interfaceByteBufHolder- Specified by:
retainedDuplicatein interfaceHttpData- See Also:
-
replace
Description copied from interface:ByteBufHolderReturns a newByteBufHolderwhich contains the specifiedcontent.- Specified by:
replacein interfaceByteBufHolder- Specified by:
replacein interfaceHttpData
-
retain
FileUpload retain()Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfaceHttpData- Specified by:
retainin interfaceInterfaceHttpData- Specified by:
retainin interfaceReferenceCounted
-
retain
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceByteBufHolder- Specified by:
retainin interfaceHttpData- Specified by:
retainin interfaceInterfaceHttpData- Specified by:
retainin interfaceReferenceCounted
-
touch
FileUpload touch()Description copied from interface:ReferenceCountedRecords the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector. This method is a shortcut totouch(null).- Specified by:
touchin interfaceByteBufHolder- Specified by:
touchin interfaceHttpData- Specified by:
touchin interfaceInterfaceHttpData- Specified by:
touchin interfaceReferenceCounted
-
touch
Description copied from interface:ReferenceCountedRecords the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector.- Specified by:
touchin interfaceByteBufHolder- Specified by:
touchin interfaceHttpData- Specified by:
touchin interfaceInterfaceHttpData- Specified by:
touchin interfaceReferenceCounted
-