Top Description Methods
io.netty.contrib.handler.codec.http.multipart

public Interface HttpData

extends InterfaceHttpData
Known Direct Subinterfaces
io.netty.contrib.handler.codec.http.multipart.Attribute, io.netty.contrib.handler.codec.http.multipart.FileUpload
Known Direct Implementers
io.netty.contrib.handler.codec.http.multipart.AbstractHttpData, io.netty.contrib.handler.codec.http.multipart.AbstractMixedHttpData
Imports
io.netty5.buffer.Buffer, io.netty.contrib.handler.codec.http.multipart.Helpers.ThrowingConsumer, java.io.File, .IOException, .InputStream, java.nio.charset.Charset

Extended interface for InterfaceHttpData

Method Summary

Modifier and TypeMethod and Description
public void
addContent(Buffer
must be not null except if last is set to False
buffer
,
boolean
True of the buffer is the last one
last
)

Add the content from the ChannelBuffer

Buffer#close() ownership of buffer is transferred to this HttpData.

public void
checkSize(long newSize)

Check if the new size is not reaching the max limit allowed.

public HttpData
copy()

Creates a deep copy of this HttpData.

public long

Returns:

the defined length of the HttpData
definedLength
()

Returns the defined length of the HttpData.

public void
delete()

Deletes the underlying storage for a file item, including deleting any associated temporary disk file.

public byte[]

Returns:

the contents of the file item as an array of bytes.
get
()

Returns the contents of the file item as an array of bytes.

public Charset

Returns:

the Charset passed by the browser or null if not defined.
getCharset
()

Returns the Charset passed by the browser or null if not defined.

public Buffer

Returns:

a ChannelBuffer for the content from the current position or an EMPTY_BUFFER if there is no more data to return
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.

public File

Returns:

the associated File if this data is represented in a file
getFile
()

public long
getMaxSize()

Returns the maxSize for this HttpData.

public String

Returns:

the contents of the file item as a String, using the default character encoding.
getString
()

Returns the contents of the file item as a String, using the default character encoding.

public String

Returns:

the contents of the file item as a String, using the specified charset.
getString
(Charset
the charset to use
encoding
)

Returns the contents of the file item as a String, using the specified charset.

public boolean

Returns:

True if the InterfaceHttpData is completed (all data are stored)
isCompleted
()

public boolean

Returns:

True if the file contents is in memory.
isInMemory
()

Provides a hint as to whether or not the file contents will be read from memory.

public long

Returns:

the size of the InterfaceHttpData
length
()

Returns the size in byte of the InterfaceHttpData

public boolean

Returns:

True if the write is successful
renameTo
(File
destination file - must be not null
dest
)

A convenience getMethod to write an uploaded item to disk.

public HttpData
replace(Buffer content)

Returns a new HttpData which contains the specified content.

public void
setCharset(Charset
Charset to set - must be not null
charset
)

Set the Charset passed by the browser if defined

public void
setContent(Buffer
must be not null
buffer
)

Set the content from the ChannelBuffer (erase any previous data)

Buffer#close() ownership of buffer is transferred to this HttpData.

public void
setContent(File
must be not null
file
)

Set the content from the file (erase any previous data)

public void
setContent(InputStream
must be not null
inputStream
)

Set the content from the inputStream (erase any previous data)

public void
setMaxSize(long maxSize)

Set the maxSize for this HttpData.

public <
the type of the exception thrown by the callback
E extends Exception
>
void
usingBuffer(Helpers.ThrowingConsumer<Buffer, E>
The file item buffer callback
callback
)

Calls the passed callback to operate on the file item as a Buffer.

public <
the type of the exception thrown by the callback
E extends Exception
>
void
usingContent(Helpers.ThrowingConsumer<Buffer, E>
The file item buffer callback
callback
)

Calls the passed callback to operate on the file item as a Buffer.

Inherited from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpData:
getHttpDataTypegetName

Method Detail

addContentback to summary
public void addContent(Buffer buffer, boolean last) throws IOException

Add the content from the ChannelBuffer

Buffer#close() ownership of buffer is transferred to this HttpData.

Parameters
buffer:Buffer

must be not null except if last is set to False

last:boolean

True of the buffer is the last one

checkSizeback to summary
public void checkSize(long newSize) throws IOException

Check if the new size is not reaching the max limit allowed. The limit is always computed in terms of bytes.

copyback to summary
public HttpData copy()

Creates a deep copy of this HttpData.

definedLengthback to summary
public long definedLength()

Returns the defined length of the HttpData. If no Content-Length is provided in the request, the defined length is always 0 (whatever during decoding or in final state). If Content-Length is provided in the request, this is this given defined length. This value does not change, whatever during decoding or in the final state. This method could be used for instance to know the amount of bytes transmitted for one particular HttpData, for example one FileUpload or any known big Attribute.

Returns:long

the defined length of the HttpData

deleteback to summary
public void delete()

Deletes the underlying storage for a file item, including deleting any associated temporary disk file.

getback to summary
public byte[] get() throws IOException

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:byte[]

the contents of the file item as an array of bytes.

getCharsetback to summary
public Charset getCharset()

Returns the Charset passed by the browser or null if not defined.

Returns:Charset

the Charset passed by the browser or null if not defined.

getChunkback to summary
public Buffer getChunk(int length) throws IOException

Returns a ChannelBuffer for the content from the current position with at most length read bytes, increasing the current position of the Bytes read. Once it arrives at the end, it returns an EMPTY_BUFFER and it resets the current position to 0.

Buffer ownersip: The buffer ownership of the returned buffer is transferred to the caller

Returns:Buffer

a ChannelBuffer for the content from the current position or an EMPTY_BUFFER if there is no more data to return

getFileback to summary
public File getFile() throws IOException
Returns:File

the associated File if this data is represented in a file

Exceptions
IOException:
if this data is not represented by a file
getMaxSizeback to summary
public long getMaxSize()

Returns the maxSize for this HttpData.

getStringback to summary
public String getString() throws IOException

Returns the contents of the file item as a String, using the default character encoding.

Returns:String

the contents of the file item as a String, using the default character encoding.

getStringback to summary
public String getString(Charset encoding) throws IOException

Returns the contents of the file item as a String, using the specified charset.

Parameters
encoding:Charset

the charset to use

Returns:String

the contents of the file item as a String, using the specified charset.

isCompletedback to summary
public boolean isCompleted()
Returns:boolean

True if the InterfaceHttpData is completed (all data are stored)

isInMemoryback to summary
public boolean isInMemory()

Provides a hint as to whether or not the file contents will be read from memory.

Returns:boolean

True if the file contents is in memory.

lengthback to summary
public long length()

Returns the size in byte of the InterfaceHttpData

Returns:long

the size of the InterfaceHttpData

renameToback to summary
public boolean renameTo(File dest) throws IOException

A convenience getMethod to write an uploaded item to disk. If a previous one exists, it will be deleted. Once this getMethod is called, if successful, the new file will be out of the cleaner of the factory that creates the original InterfaceHttpData object.

Parameters
dest:File

destination file - must be not null

Returns:boolean

True if the write is successful

replaceback to summary
public HttpData replace(Buffer content)

Returns a new HttpData which contains the specified content.

setCharsetback to summary
public void setCharset(Charset charset)

Set the Charset passed by the browser if defined

Parameters
charset:Charset

Charset to set - must be not null

setContentback to summary
public void setContent(Buffer buffer) throws IOException

Set the content from the ChannelBuffer (erase any previous data)

Buffer#close() ownership of buffer is transferred to this HttpData.

Parameters
buffer:Buffer

must be not null

setContentback to summary
public void setContent(File file) throws IOException

Set the content from the file (erase any previous data)

Parameters
file:File

must be not null

setContentback to summary
public void setContent(InputStream inputStream) throws IOException

Set the content from the inputStream (erase any previous data)

Parameters
inputStream:InputStream

must be not null

setMaxSizeback to summary
public void setMaxSize(long maxSize)

Set the maxSize for this HttpData. When limit will be reached, an exception will be raised. Setting it to (-1) means no limitation. By default, to be set from the HttpDataFactory.

usingBufferback to summary
public <E extends Exception> void usingBuffer(Helpers.ThrowingConsumer<Buffer, E> callback) throws IOException, ThrowingConsumer-:E

Calls the passed callback to operate on the file item as a Buffer.

Note

this method will allocate a lot of memory, if the data is currently stored on the file system.

Buffer ownersip:

The ownership of the buffer passed to the callack is not transferred and remains to this HttpData interface.
  • for memory based http data, the internal buffer is directly passed to the callback.
  • for disk based http data, a copy of the file content is passed to the callback and is immediately closed once the callback returns.
Parameters
<E>
the type of the exception thrown by the callback
callback:Helpers.ThrowingConsumer<Buffer, E>

The file item buffer callback

Exceptions
IOException:
if the method can't load the buffer from disk
ThrowingConsumer-:E:
if the callback throws that exception
usingContentback to summary
public <E extends Exception> void usingContent(Helpers.ThrowingConsumer<Buffer, E> callback) throws ThrowingConsumer-:E

Calls the passed callback to operate on the file item as a Buffer.

Note

this method will allocate a lot of memory, if the data is currently stored on the file system.

Buffer ownersip:

The ownership of the buffer passed to the callack is not transferred and remains to this HttpData interface.
  • for memory based http data, the internal buffer is directly passed to the callback.
  • for disk based http data, a copy of the file content is passed to the callback and is immediately closed once the callback returns.
Parameters
<E>
the type of the exception thrown by the callback
callback:Helpers.ThrowingConsumer<Buffer, E>

The file item buffer callback

Exceptions
ThrowingConsumer-:E:
if the callback throws that exception