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

public abstract Class AbstractDiskHttpData

extends AbstractHttpData
Class Inheritance
Known Direct Subclasses
io.netty.handler.codec.http.multipart.DiskAttribute, io.netty.handler.codec.http.multipart.DiskFileUpload
Imports
io.netty.buffer.ByteBuf, io.netty.handler.codec.http.HttpConstants, io.netty.util.internal.EmptyArrays, .ObjectUtil, .PlatformDependent, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.io.File, .IOException, .InputStream, .RandomAccessFile, java.nio.ByteBuffer, java.nio.channels.FileChannel, java.nio.charset.Charset

Abstract Disk HttpData implementation

Field Summary

Modifier and TypeField and Description
private File
private FileChannel
private boolean
private static final InternalLogger
Inherited from io.netty.handler.codec.http.multipart.AbstractHttpData:
definedSizesize

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
public void
addContent(ByteBuf
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.handler.codec.http.multipart.HttpData.addContent.

Add the content from the ChannelBuffer

ByteBuf#release() ownership of buffer is transferred to this HttpData.

public void
delete()

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

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

Returns:

True if the file should be deleted on Exit by default
deleteOnExit
()

public byte[]
get()

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

Returns the contents of the file item as an array of bytes.
protected abstract String

Returns:

the default base Directory
getBaseDirectory
()

public ByteBuf
getByteBuf()

Implements io.netty.handler.codec.http.multipart.HttpData.getByteBuf.

Returns the content of the file item as a ByteBuf.
public ByteBuf
getChunk(int length)

Implements io.netty.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.
protected abstract String

Returns:

the real DiskFilename (basename)
getDiskFilename
()

public File
protected abstract String

Returns:

the default postfix
getPostfix
()

protected abstract String

Returns:

the default prefix
getPrefix
()

public String
getString()

Implements io.netty.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.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.handler.codec.http.multipart.HttpData.isInMemory.

Provides a hint as to whether or not the file contents will be read from memory.
private static byte[]

Returns:

the array of bytes
readFrom
(File src)

Utility function

public boolean
renameTo(File
destination file - must be not null
dest
)

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

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

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

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

ByteBuf#release() ownership of buffer is transferred to this HttpData.

public void
setContent(File
must be not null
file
)

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

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

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

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

Returns:

a new Temp File from getDiskFilename(), default prefix, postfix and baseDirectory
tempFile
()

public HttpData
touch()

Implements abstract io.netty.handler.codec.http.multipart.AbstractHttpData.touch.

Implements io.netty.handler.codec.http.multipart.HttpData.touch, io.netty.util.ReferenceCounted.touch.

Records the current access location of this object for debugging purposes.
public HttpData
touch(Object hint)

Implements abstract io.netty.handler.codec.http.multipart.AbstractHttpData.touch.

Implements io.netty.handler.codec.http.multipart.HttpData.touch, io.netty.util.ReferenceCounted.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes.
Inherited from io.netty.handler.codec.http.multipart.AbstractHttpData:
checkSizecontentdeallocatedefinedLengthgetCharsetgetMaxSizegetNameisCompletedlengthretainretainsetCharsetsetCompletedsetCompletedsetMaxSize

Field Detail

fileback to summary
private File file
fileChannelback to summary
private FileChannel fileChannel
isRenamedback to summary
private boolean isRenamed
loggerback to summary
private static final InternalLogger logger

Constructor Detail

AbstractDiskHttpDataback to summary
protected AbstractDiskHttpData(String name, Charset charset, long size)

Method Detail

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

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

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

Add the content from the ChannelBuffer

ByteBuf#release() ownership of buffer is transferred to this HttpData.

Parameters
buffer:ByteBuf

must be not null except if last is set to False

last:boolean

True of the buffer is the last one

Annotations
@Override
deleteback to summary
public void delete()

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

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

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

Annotations
@Override
deleteOnExitback to summary
protected abstract boolean deleteOnExit()
Returns:boolean

True if the file should be deleted on Exit by default

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

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

Doc from io.netty.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
getBaseDirectoryback to summary
protected abstract String getBaseDirectory()
Returns:String

the default base Directory

getByteBufback to summary
public ByteBuf getByteBuf() throws IOException

Implements io.netty.handler.codec.http.multipart.HttpData.getByteBuf.

Doc from io.netty.handler.codec.http.multipart.HttpData.getByteBuf.

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:ByteBuf

the content of the file item as a ByteBuf

Annotations
@Override
getChunkback to summary
public ByteBuf getChunk(int length) throws IOException

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

Doc from io.netty.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.

Returns:ByteBuf

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

Annotations
@Override
getDiskFilenameback to summary
protected abstract String getDiskFilename()
Returns:String

the real DiskFilename (basename)

getFileback to summary
public File getFile() throws IOException

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

Returns:File

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

if this data is not represented by a file

getPostfixback to summary
protected abstract String getPostfix()
Returns:String

the default postfix

getPrefixback to summary
protected abstract String getPrefix()
Returns:String

the default prefix

getStringback to summary
public String getString() throws IOException

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

Doc from io.netty.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) throws IOException

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

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

Doc from io.netty.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
readFromback to summary
private static byte[] readFrom(File src) throws IOException

Utility function

Returns:byte[]

the array of bytes

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

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

Doc from io.netty.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(ByteBuf buffer) throws IOException

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

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

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

ByteBuf#release() ownership of buffer is transferred to this HttpData.

Parameters
buffer:ByteBuf

must be not null

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

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

Doc from io.netty.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
setContentback to summary
public void setContent(InputStream inputStream) throws IOException

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

Doc from io.netty.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
tempFileback to summary
private File tempFile() throws IOException
Returns:File

a new Temp File from getDiskFilename(), default prefix, postfix and baseDirectory

touchback to summary
public HttpData touch()

Implements abstract io.netty.handler.codec.http.multipart.AbstractHttpData.touch.

Implements io.netty.handler.codec.http.multipart.HttpData.touch, io.netty.util.ReferenceCounted.touch.

Doc from io.netty.util.ReferenceCounted.touch.

Records 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 via ResourceLeakDetector. This method is a shortcut to touch(null).

Annotations
@Override
touchback to summary
public HttpData touch(Object hint)

Implements abstract io.netty.handler.codec.http.multipart.AbstractHttpData.touch.

Implements io.netty.handler.codec.http.multipart.HttpData.touch, io.netty.util.ReferenceCounted.touch.

Doc from io.netty.util.ReferenceCounted.touch.

Records 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 via ResourceLeakDetector.

Annotations
@Override