request.response.sendFile(fileName);
http://vertx.io/api/java/api/org/vertx/java/core/http/HttpServerResponse.html#sendFile(java.lang.String)
But you still have to set the Content-Type
On Tuesday, March 12, 2013 5:11:24 PM UTC+1, elliot wrote:Is there any in-built method for serving image files over http(s), rather than doing something like this:
request.response.putHeader("content-type", "image/*");
String fileName = "myfile.jpg";
File file = new File(fileName);Elliot
byte[] fileContent = Files.readAllBytes(file.toPath());
request.response.writeBuffer(new Buffer().appendBytes(fileContent));
request.response.end();
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
On 12/03/13 17:15, Christian Essl wrote:
request.response.sendFile(fileName);
http://vertx.io/api/java/api/org/vertx/java/core/http/HttpServerResponse.html#sendFile(java.lang.String)
But you still have to set the Content-Type
Actually - it should set content-type automatically for most common types :)