vertx / io.vertx.core.http / HttpServerResponse / sendFile

# sendFile

`open fun sendFile(filename: String): HttpServerResponse`

Same as `#sendFile(String, long)` using offset @code{0} which means starting from the beginning of the file.

### Parameters

`filename` - path to the file to serve

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

`open fun sendFile(filename: String, offset: Long): HttpServerResponse`

Same as `#sendFile(String, long, long)` using length @code{Long.MAX_VALUE} which means until the end of the file.

### Parameters

`filename` - path to the file to serve

`offset` - offset to start serving from

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

`abstract fun sendFile(filename: String, offset: Long, length: Long): HttpServerResponse`

Ask the OS to stream a file as specified by `filename` directly from disk to the outgoing connection, bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to serve files.

The actual serve is asynchronous and may not complete until some time after this method has returned.

### Parameters

`filename` - path to the file to serve

`offset` - offset to start serving from

`length` - length to serve to

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

`open fun sendFile(filename: String, resultHandler: Handler<AsyncResult<Void>>): HttpServerResponse`

Like `#sendFile(String)` but providing a handler which will be notified once the file has been completely written to the wire.

### Parameters

`filename` - path to the file to serve

`resultHandler` - handler that will be called on completion

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

`open fun sendFile(filename: String, offset: Long, resultHandler: Handler<AsyncResult<Void>>): HttpServerResponse`

Like `#sendFile(String, long)` but providing a handler which will be notified once the file has been completely written to the wire.

### Parameters

`filename` - path to the file to serve

`offset` - the offset to serve from

`resultHandler` - handler that will be called on completion

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

`abstract fun sendFile(filename: String, offset: Long, length: Long, resultHandler: Handler<AsyncResult<Void>>): HttpServerResponse`

Like `#sendFile(String, long, long)` but providing a handler which will be notified once the file has been completely written to the wire.

### Parameters

`filename` - path to the file to serve

`offset` - the offset to serve from

`length` - the length to serve to

`resultHandler` - handler that will be called on completion

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