Package com.google.appengine.api.files

Examples of com.google.appengine.api.files.FileService.openWriteChannel()


    Image newImage = imagesService.applyTransform(crop, oldImage);
    FileService fileService = FileServiceFactory.getFileService();
    AppEngineFile file = fileService.createNewBlobFile("image/jpg");
    byte[] data = newImage.getImageData();

    FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
    // This time we write to the channel directly
    writeChannel.write(ByteBuffer.wrap(data));
    // Now finalize
    writeChannel.closeFinally();
    //if(blobKey !=null) //delete the existing blob first -- GOT ERROR here....
View Full Code Here


  //======================HELPER METHODS==================================
  private String createImage() throws IOException, FileNotFoundException,
      FinalizationException, LockException {
    FileService fileService = FileServiceFactory.getFileService();
    AppEngineFile file = fileService.createNewBlobFile("text/plain");
    FileWriteChannel writeChannel = fileService
        .openWriteChannel(file, true);
    PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel,
        "UTF8"));
    out.println("Hello");
    out.close();
View Full Code Here

  }

  public BlobKey writeJpegImage(byte[] bytes) throws IOException{
    FileService fileService = FileServiceFactory.getFileService();
    AppEngineFile file = fileService.createNewBlobFile("image/jpeg");
    FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
    OutputStream out = (Channels.newOutputStream(writeChannel));
    out.write(bytes);
    out.close();
    writeChannel.closeFinally();
   
View Full Code Here

  }
  private BlobKey persistBlob() throws IOException, FileNotFoundException,
      FinalizationException, LockException {
    FileService fileService = FileServiceFactory.getFileService();
    AppEngineFile file = fileService.createNewBlobFile("image/jpeg");
    FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
    PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"));
    out.println("Hello");
    out.close();
    writeChannel.closeFinally();
   
View Full Code Here

    }

    protected BlobKey writeNewBlobFile(String text) throws IOException {
        FileService fileService = FileServiceFactory.getFileService();
        AppEngineFile file = fileService.createNewBlobFile("text/plain", "uploadedText.txt");
        FileWriteChannel channel = fileService.openWriteChannel(file, true);
        try {
            channel.write(ByteBuffer.wrap(text.getBytes()));
        } finally {
            channel.closeFinally();
        }
View Full Code Here

            entity = ds.get(key);
            log.info(entity.toString());

            FileService fs = FileServiceFactory.getFileService();
            AppEngineFile file = fs.createNewBlobFile("qwertfile");
            FileWriteChannel fwc = fs.openWriteChannel(file, false);
            try {
                log.info("b_l = " + fwc.write(ByteBuffer.wrap("qwert".getBytes())));
            } finally {
                fwc.close();
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.