use of org.apache.commons.io.output.ByteArrayOutputStream in project vboard by voyages-sncf-technologies.
the class UploadsManager method getImage.
/**
* Get the base64 encoded image of a pin (entry parameter: id)
*
* @return String base64 encoded image
*/
public String getImage(String name) {
try {
BufferedImage img = ImageIO.read(getPinsImagesDirectory().resolve(name + ".png").toFile());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(img, "png", bos);
byte[] imageBytes = bos.toByteArray();
bos.close();
return Base64.getEncoder().encodeToString(imageBytes);
} catch (IOException e) {
throw new VBoardException("Image encoding error", e);
}
}
use of org.apache.commons.io.output.ByteArrayOutputStream in project mica2 by obiba.
the class DataAccessRequestsResource method exportCsv.
@GET
@Timed
@Path("/csv")
@Produces("text/csv")
public Response exportCsv(@QueryParam("lang") String lang) {
List<DataAccessRequest> dataAccessRequests = listByStatusFilteringPermitted(null);
DataAccessForm dataAccessForm = dataAccessFormService.find().get();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
new CsvReportGenerator(dataAccessRequests, dataAccessForm.getCsvExportFormat(), lang).write(byteArrayOutputStream);
String date = new DateTime().toString("YYYY-MM-dd");
return Response.ok(byteArrayOutputStream.toByteArray()).header("Content-Disposition", String.format("attachment; filename=\"Access-Requests-Report_%s.csv\"", date)).build();
}
Aggregations