Top Description Fields Constructors Methods
io.vertx.core.http.impl

pack-priv Class HttpServerFileUploadImpl

extends Object
implements HttpServerFileUpload
Class Inheritance
All Implemented Interfaces
io.vertx.core.http.HttpServerFileUpload, io.vertx.core.streams.ReadStream, io.vertx.core.streams.StreamBase
Imports
io.vertx.core.AsyncResult, .Future, .Handler, io.vertx.core.buffer.Buffer, io.vertx.core.file.AsyncFile, .FileSystem, .OpenOptions, io.vertx.core.http.HttpServerFileUpload, io.vertx.core.impl.ContextInternal, io.vertx.core.streams.Pipe, .ReadStream, java.nio.charset.Charset

This class is optimised for performance when used on the same event loop that is was passed to the handler with. However it can be used safely from other threads. The internal state is protected using the synchronized keyword. If always used on the same event loop, then we benefit from biased locking which makes the overhead of synchronized near zero.
Author
Norman Maurer

Field Summary

Modifier and TypeField and Description
private boolean
private final Charset
private final String
private final String
private final ContextInternal
private Handler<Buffer>
private Handler<Void>
private Handler<Throwable>
private AsyncFile
private final String
private boolean
private final String
private Pipe<Buffer>
private long
private final ReadStream<Buffer>

Constructor Summary

AccessConstructor and Description
pack-priv
HttpServerFileUploadImpl(ContextInternal context, ReadStream<Buffer> stream, String name, String filename, String contentType, String contentTransferEncoding, Charset charset, long size)

Method Summary

Modifier and TypeMethod and Description
public boolean
cancelStreamToFileSystem()

Implements io.vertx.core.http.HttpServerFileUpload.cancelStreamToFileSystem.

Try to cancel the file system streaming, the streamed file will be deleted.

public String
public String
public String
public synchronized HttpServerFileUpload
public synchronized HttpServerFileUpload
public HttpServerFileUpload
fetch(long amount)

Implements io.vertx.core.http.HttpServerFileUpload.fetch.

Fetch the specified amount of elements.

public synchronized AsyncFile
public String
private void
handleData(Buffer data)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

private void
private void
public synchronized HttpServerFileUpload
public synchronized boolean
public String
public HttpServerFileUpload
pause()

Implements io.vertx.core.http.HttpServerFileUpload.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

public HttpServerFileUpload
resume()

Implements io.vertx.core.http.HttpServerFileUpload.resume.

Resume reading, and sets the buffer in flowing mode.

public synchronized long
size()

Implements io.vertx.core.http.HttpServerFileUpload.size.

The size of the upload may not be available until it is all read.

public void
streamToFileSystem(String
the name of the file
filename
,
Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.http.HttpServerFileUpload.streamToFileSystem.

Stream the content of this upload to the given file on storage.

public Future<Void>
streamToFileSystem(String
the name of the file
filename
)

Implements io.vertx.core.http.HttpServerFileUpload.streamToFileSystem.

Stream the content of this upload to the given file on storage.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cancelledback to summary
private boolean cancelled
charsetback to summary
private final Charset charset
contentTransferEncodingback to summary
private final String contentTransferEncoding
contentTypeback to summary
private final String contentType
contextback to summary
private final ContextInternal context
dataHandlerback to summary
private Handler<Buffer> dataHandler
endHandlerback to summary
private Handler<Void> endHandler
exceptionHandlerback to summary
private Handler<Throwable> exceptionHandler
fileback to summary
private AsyncFile file
filenameback to summary
private final String filename
lazyCalculateSizeback to summary
private boolean lazyCalculateSize
nameback to summary
private final String name
pipeback to summary
private Pipe<Buffer> pipe
sizeback to summary
private long size
streamback to summary
private final ReadStream<Buffer> stream

Constructor Detail

HttpServerFileUploadImplback to summary
pack-priv HttpServerFileUploadImpl(ContextInternal context, ReadStream<Buffer> stream, String name, String filename, String contentType, String contentTransferEncoding, Charset charset, long size)

Method Detail

cancelStreamToFileSystemback to summary
public boolean cancelStreamToFileSystem()

Implements io.vertx.core.http.HttpServerFileUpload.cancelStreamToFileSystem.

Doc from io.vertx.core.http.HttpServerFileUpload.cancelStreamToFileSystem.

Try to cancel the file system streaming, the streamed file will be deleted.

Returns:boolean

true when the stream is cancelled, otherwise it means that stream is finished

Annotations
@Override
charsetback to summary
public String charset()

Implements io.vertx.core.http.HttpServerFileUpload.charset.

Returns:String

Doc from io.vertx.core.http.HttpServerFileUpload.charset.

the charset for the upload

Annotations
@Override
contentTransferEncodingback to summary
public String contentTransferEncoding()

Implements io.vertx.core.http.HttpServerFileUpload.contentTransferEncoding.

Returns:String

Doc from io.vertx.core.http.HttpServerFileUpload.contentTransferEncoding.

the contentTransferEncoding for the upload

Annotations
@Override
contentTypeback to summary
public String contentType()

Implements io.vertx.core.http.HttpServerFileUpload.contentType.

Returns:String

Doc from io.vertx.core.http.HttpServerFileUpload.contentType.

the content type for the upload

Annotations
@Override
endHandlerback to summary
public synchronized HttpServerFileUpload endHandler(Handler<Void> handler)

Implements io.vertx.core.http.HttpServerFileUpload.endHandler.

Annotations
@Override
exceptionHandlerback to summary
public synchronized HttpServerFileUpload exceptionHandler(Handler<Throwable> exceptionHandler)

Implements io.vertx.core.http.HttpServerFileUpload.exceptionHandler.

Annotations
@Override
fetchback to summary
public HttpServerFileUpload fetch(long amount)

Implements io.vertx.core.http.HttpServerFileUpload.fetch.

Doc from io.vertx.core.streams.ReadStream.fetch.

Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.

Returns:HttpServerFileUpload

a reference to this, so the API can be used fluently

Annotations
@Override
fileback to summary
public synchronized AsyncFile file()

Implements io.vertx.core.http.HttpServerFileUpload.file.

Returns:AsyncFile

Doc from io.vertx.core.http.HttpServerFileUpload.file.

the async uploaded file when streamToFileSystem has been used and the file is available

Annotations
@Override
filenameback to summary
public String filename()

Implements io.vertx.core.http.HttpServerFileUpload.filename.

Returns:String

Doc from io.vertx.core.http.HttpServerFileUpload.filename.

the filename which was used when upload the file.

Annotations
@Override
handleDataback to summary
private void handleData(Buffer data)

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

handleEndback to summary
private void handleEnd()
handleExceptionback to summary
private void handleException(Throwable cause)
handlerback to summary
public synchronized HttpServerFileUpload handler(Handler<Buffer> handler)

Implements io.vertx.core.http.HttpServerFileUpload.handler.

Annotations
@Override
isSizeAvailableback to summary
public synchronized boolean isSizeAvailable()

Implements io.vertx.core.http.HttpServerFileUpload.isSizeAvailable.

Returns:boolean

Doc from io.vertx.core.http.HttpServerFileUpload.isSizeAvailable.

true if the size of the upload can be retrieved via size().

Annotations
@Override
nameback to summary
public String name()

Implements io.vertx.core.http.HttpServerFileUpload.name.

Returns:String

Doc from io.vertx.core.http.HttpServerFileUpload.name.

the name of the attribute

Annotations
@Override
pauseback to summary
public HttpServerFileUpload pause()

Implements io.vertx.core.http.HttpServerFileUpload.pause.

Doc from io.vertx.core.streams.ReadStream.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

While it's paused, no data will be sent to the data handler.

Returns:HttpServerFileUpload

a reference to this, so the API can be used fluently

Annotations
@Override
resumeback to summary
public HttpServerFileUpload resume()

Implements io.vertx.core.http.HttpServerFileUpload.resume.

Doc from io.vertx.core.streams.ReadStream.resume.

Resume reading, and sets the buffer in flowing mode.

If the ReadStream has been paused, reading will recommence on it.

Returns:HttpServerFileUpload

a reference to this, so the API can be used fluently

Annotations
@Override
sizeback to summary
public synchronized long size()

Implements io.vertx.core.http.HttpServerFileUpload.size.

Doc from io.vertx.core.http.HttpServerFileUpload.size.

The size of the upload may not be available until it is all read. Check isSizeAvailable to determine this

Returns:long

the size of the upload (in bytes)

Annotations
@Override
streamToFileSystemback to summary
public void streamToFileSystem(String filename, Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.http.HttpServerFileUpload.streamToFileSystem.

Doc from io.vertx.core.http.HttpServerFileUpload.streamToFileSystem.

Stream the content of this upload to the given file on storage.

Parameters
filename:String

the name of the file

Annotations
@Override
streamToFileSystemback to summary
public Future<Void> streamToFileSystem(String filename)

Implements io.vertx.core.http.HttpServerFileUpload.streamToFileSystem.

Doc from io.vertx.core.http.HttpServerFileUpload.streamToFileSystem.

Stream the content of this upload to the given file on storage.

If the stream has a failure or is cancelled the created file will be deleted.

Parameters
filename:String

the name of the file

Annotations
@Override