Examples of closeFinally()


Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

    AppEngineFile blobFile = fileService.createNewBlobFile("application/bin");
    FileWriteChannel writeChannel = fileService.openWriteChannel(blobFile, true);
    for (int i = 0; i < recordsCount; i++) {
      writeChannel.write(ByteBuffer.wrap(record.getBytes()));
    }
    writeChannel.closeFinally();
    blobKey = fileService.getBlobKey(blobFile);
    blobSize = new BlobInfoFactory().loadBlobInfo(blobKey).getSize();
  }
}
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

    FileWriteChannel blobChannel = newBlobChannel(blobName, contentType);
   
    OutputStream ostream = Channels.newOutputStream(blobChannel);
    ostream.write(data);
    ostream.flush();
    blobChannel.closeFinally();
  }

  private static FileWriteChannel newBlobChannel(String blobName, String contentType) throws IOException {
    FileService fileService = FileServiceFactory.getFileService();
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

      logger.warning("IOException: " + e);
      e.printStackTrace();
      throw e;
    } finally {
      try {
        if(writeChannel != null && writeChannel.isOpen()) writeChannel.closeFinally();
      } catch (IllegalStateException e) {
        logger.warning("IllegalStateException: " + e);
      } catch (IOException e) {
        logger.warning("IOException: " + e);
      }
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

    // This time we write to the channel directly
    writeChannel.write(ByteBuffer.wrap(imageData.getBytes()));

    // Now finalize
    writeChannel.closeFinally();
    return fileService.getBlobKey(file);
  }
}
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

    FileWriteChannel writeChannel = fileService.openWriteChannel(file, lock);
    // Different standard Java ways of writing to the channel
    // are possible. Here we use a PrintWriter:
    writeChannel.write(ByteBuffer.wrap(content));
    // Now finalize
    writeChannel.closeFinally();
    BlobKey key = fileService.getBlobKey(file);
    return key.getKeyString();
  }
 
  public static void deleteFile(String key) {
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

      AppEngineFile file = fileService.createNewBlobFile("image/" + originalImage.getFormat());
      FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
      ByteBuffer buffer = ByteBuffer.wrap(originalImage.getImageData());
      writeChannel.write(buffer);
      writeChannel.closeFinally();
      BlobKey key = fileService.getBlobKey(file);
      String servingURL = imagesService.getServingUrl(key);
      if (servingURL != null) {
        this.url = servingURL;
      }
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

      AppEngineFile file = fileService.createNewBlobFile("text/plain", fileName);
     
      // Open a channel to write to it
      FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
      writeChannel.write(ByteBuffer.wrap(rawData));     
      writeChannel.closeFinally();
     
      logger.info("Uploaded file name : " + fileName + " path : " + file.getFullPath() + " with size = " + rawData.length);
     
      // step 3 : send result back to client
      BlobUploadResult result = AutoBeanUtil.newBlobUploadResult(Status.SUCCESS, fileName, rawData.length);
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

            writer.print(memo.getMemo());
            writer.print("\"");
            writer.println();
        }
        writer.close();
        writeChannel.closeFinally();
        return fileService.getBlobKey(file);
    }
}
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

        FileWriteChannel writeChannel =
            fileService.openWriteChannel(file, true);
        OutputStream output = Channels.newOutputStream(writeChannel);
        output.write(imageBytes);
        output.close();
        writeChannel.closeFinally();
        BlobKey blobKey = fileService.getBlobKey(file);
        // test@example.com というユーザがログイン中、という状態を作っておく。
        TestEnvironment environment =
            (TestEnvironment) ApiProxy.getCurrentEnvironment();
        environment.setEmail("test@example.com");
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

      {
         writeChannel.write(ByteBuffer.wrap(bytes));
      }
      finally
      {
         writeChannel.closeFinally();
      }
      BlobKey blobKey = fileService.getBlobKey(file);
      return blobKey.getKeyString();
   }
}
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.