use of org.restlet.resource.StreamRepresentation in project GeoGig by boundlessgeo.
the class ConsoleResourceResource method handleGet.
@Override
public void handleGet() {
final String resourceName;
{
String res = RESTUtils.getStringAttribute(getRequest(), "resource");
if (null == res) {
resourceName = "terminal.html";
} else {
resourceName = res;
}
}
MediaType mediaType = guessMediaType(resourceName);
getResponse().setEntity(new StreamRepresentation(mediaType) {
@Override
public void write(OutputStream outputStream) throws IOException {
// System.out.println("returning " + resourceName);
ByteStreams.copy(getStream(), outputStream);
}
@Override
public InputStream getStream() throws IOException {
InputStream inputStream = ConsoleResourceResource.class.getResourceAsStream(resourceName);
return inputStream;
}
});
}
Aggregations