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

public abstract Class AbstractMemoryHttpData

extends AbstractHttpData
Class Inheritance
Known Direct Subclasses
io.netty.contrib.handler.codec.http.multipart.MemoryAttribute, io.netty.contrib.handler.codec.http.multipart.MemoryFileUpload
Imports
io.netty5.buffer.Buffer, .CompositeBuffer, .DefaultBufferAllocators, io.netty5.buffer.internal.InternalBufferUtils, io.netty5.handler.codec.http.HttpConstants, io.netty5.util.internal.ObjectUtil, io.netty.contrib.handler.codec.http.multipart.Helpers.ThrowingConsumer, java.io.File, .IOException, .InputStream, .RandomAccessFile, java.nio.channels.FileChannel, java.nio.charset.Charset, java.util.Arrays

Abstract Memory HttpData implementation

Field Summary

Modifier and TypeField and Description
protected Buffer
Inherited from io.netty.contrib.handler.codec.http.multipart.AbstractHttpData:
definedSizeEMPTY_ARRAYsize

Constructor Summary

AccessConstructor and Description
protected
AbstractMemoryHttpData(String name, Charset charset, long size)

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
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.addContent.

Add the content from the ChannelBuffer

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

protected RuntimeException
public void
delete()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.delete.

Deletes the underlying storage for a file item, including deleting any associated temporary disk file.
public byte[]
get()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.get.

Returns the contents of the file item as an array of bytes.
public Buffer
getChunk(int length)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getChunk.

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
public String
getString()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getString.

Returns the contents of the file item as a String, using the default character encoding.
public String
getString(Charset
the charset to use
encoding
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getString.

Returns the contents of the file item as a String, using the specified charset.
public boolean
isInMemory()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.isInMemory.

Provides a hint as to whether or not the file contents will be read from memory.
public boolean
renameTo(File
destination file - must be not null
dest
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.renameTo.

A convenience getMethod to write an uploaded item to disk.
public void
setContent(Buffer
must be not null
buffer
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.setContent.

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

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

public void
setContent(InputStream
must be not null
inputStream
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.setContent.

Set the content from the inputStream (erase any previous data)
public void
setContent(File
must be not null
file
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.setContent.

Set the content from the file (erase any previous data)
protected final void
setContentInternal(Buffer buffer, long size)

public <E extends Exception> void
usingBuffer(Helpers.ThrowingConsumer<Buffer, E>
The file item buffer callback
callback
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.usingBuffer.

Utility to go from a In Memory FileUpload to a Disk (or another implementation) FileUpload
Inherited from io.netty.contrib.handler.codec.http.multipart.AbstractHttpData:
checkAccessiblecheckAccessiblecheckSizedefinedLengthgetCharsetgetMaxSizegetNameisCompletedlengthsetCharsetsetCompletedsetCompletedsetMaxSizeusingContent

Field Detail

byteBufback to summary
protected Buffer byteBuf

Constructor Detail

AbstractMemoryHttpDataback to summary
protected AbstractMemoryHttpData(String name, Charset charset, long size)

Method Detail

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

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.addContent.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.addContent.

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

Annotations
@Override
createResourceClosedExceptionback to summary
protected RuntimeException createResourceClosedException()

Overrides io.netty.contrib.handler.codec.http.multipart.AbstractHttpData.createResourceClosedException.

Annotations
@Override
deleteback to summary
public void delete()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.delete.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.delete.

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

Annotations
@Override
getback to summary
public byte[] get()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.get.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.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:byte[]

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

Annotations
@Override
getChunkback to summary
public Buffer getChunk(int length)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getChunk.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.getChunk.

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

Annotations
@Override
getFileback to summary
public File getFile() throws IOException

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getFile.

Returns:File

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.getFile.

the associated File if this data is represented in a file

Annotations
@Override
Exceptions
IOException:

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.getFile.

if this data is not represented by a file

getStringback to summary
public String getString()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getString.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.getString.

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.

Annotations
@Override
getStringback to summary
public String getString(Charset encoding)

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.getString.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.getString.

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.

Annotations
@Override
isInMemoryback to summary
public boolean isInMemory()

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.isInMemory.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.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.

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

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.renameTo.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.renameTo.

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

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

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.setContent.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.setContent.

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

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

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.setContent.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.setContent.

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

Parameters
inputStream:InputStream

must be not null

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

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.setContent.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.setContent.

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

Parameters
file:File

must be not null

Annotations
@Override
setContentInternalback to summary
protected final void setContentInternal(Buffer buffer, long size)
usingBufferback to summary
public <E extends Exception> void usingBuffer(Helpers.ThrowingConsumer<Buffer, E> callback) throws IOException, ThrowingConsumer-:E

Implements io.netty.contrib.handler.codec.http.multipart.HttpData.usingBuffer.

Utility to go from a In Memory FileUpload to a Disk (or another implementation) FileUpload

Parameters
<E>

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.usingBuffer. the type of the exception thrown by the callback

callback:Helpers.ThrowingConsumer<Buffer, E>

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.usingBuffer.

The file item buffer callback

Annotations
@Override
Exceptions
IOException:

Doc from io.netty.contrib.handler.codec.http.multipart.HttpData.usingBuffer.

if the method can't load the buffer from disk