Package net.pterodactylus.sone.data

Examples of net.pterodactylus.sone.data.TemporaryImage


        if (uploadedImage == null) {
          templateContext.set("messages", webInterface.getL10n().getString("Page.UploadImage.Error.InvalidImage"));
          return;
        }
        String mimeType = getMimeType(imageData);
        TemporaryImage temporaryImage = webInterface.getCore().createTemporaryImage(mimeType, imageData);
        image = webInterface.getCore().createImage(currentSone, parent, temporaryImage);
        image.modify().setTitle(name).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)).setWidth(uploadedImage.getWidth(null)).setHeight(uploadedImage.getHeight(null)).update();
      } catch (IOException ioe1) {
        logger.log(Level.WARNING, "Could not read uploaded image!", ioe1);
        return;
View Full Code Here


   * {@inheritDoc}
   */
  @Override
  public Response handleRequest(FreenetRequest request, Response response) throws IOException {
    String imageId = request.getHttpRequest().getParam("image");
    TemporaryImage temporaryImage = webInterface.getCore().getTemporaryImage(imageId);
    if (temporaryImage == null) {
      return response.setStatusCode(404).setStatusText("Not found.").setContentType("text/html; charset=utf-8");
    }
    String contentType= temporaryImage.getMimeType();
    return response.setStatusCode(200).setStatusText("OK").setContentType(contentType).addHeader("Content-Disposition", "attachment; filename=" + temporaryImage.getId() + "." + contentType.substring(contentType.lastIndexOf('/') + 1)).write(temporaryImage.getImageData());
  }
View Full Code Here

   * @param imageData
   *            The encoded data of the image
   * @return The temporary image
   */
  public TemporaryImage createTemporaryImage(String mimeType, byte[] imageData) {
    TemporaryImage temporaryImage = new TemporaryImage();
    temporaryImage.setMimeType(mimeType).setImageData(imageData);
    synchronized (temporaryImages) {
      temporaryImages.put(temporaryImage.getId(), temporaryImage);
    }
    return temporaryImage;
  }
View Full Code Here

TOP

Related Classes of net.pterodactylus.sone.data.TemporaryImage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.