Package com.google.appengine.api.files

Examples of com.google.appengine.api.files.AppEngineFile


  public void setUp() throws Exception {
    super.setUp();
    helper.setUp();

    FileService fileService = FileServiceFactory.getFileService();
    AppEngineFile blobFile = fileService.createNewBlobFile("application/bin");
    FileWriteChannel writeChannel = fileService.openWriteChannel(blobFile, true);
    for (int i = 0; i < RECORDS_COUNT; i++) {
      writeChannel.write(ByteBuffer.wrap(RECORD.getBytes()));
    }
    writeChannel.closeFinally();
View Full Code Here


     * @param files the file service
     * @param path the path representing an AppEngineFile
     * @return the AppEngineFile instance
     */
    public static AppEngineFile fromPath(FileService files, String path) {
        return new AppEngineFile(path);
    }
View Full Code Here

  /* to store and return the blobkey */
  private BlobKey getBlobKeyImage(BlobKey blobKey, byte[] data)
      throws IOException {
    FileService fileService = FileServiceFactory.getFileService();
    AppEngineFile file = fileService.createNewBlobFile("image/jpg");

    FileWriteChannel writeChannel = fileService
        .openWriteChannel(file, true);
    // This time we write to the channel directly
    writeChannel.write(ByteBuffer.wrap(data));
View Full Code Here

    ImagesService imagesService = ImagesServiceFactory.getImagesService();
    Image oldImage = ImagesServiceFactory.makeImageFromBlob(blobKey);
    Transform crop = ImagesServiceFactory.makeCrop(dblX1, dblY1, dblX2, dblY2);
    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));
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");
View Full Code Here

    save(entity);
  }

  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

        String mimeType = request.getParameter("mimeType");
        String contents = request.getParameter("contents");
        String blobRange = request.getParameter("blobRange");
        String name = request.getParameter("name");

        AppEngineFile file = service.createNewBlobFile(mimeType, name);
        writeToFile(file, contents);
        BlobKey blobKey = service.getBlobKey(file);

        response.addHeader("X-AppEngine-BlobKey", blobKey.getKeyString());
        if (blobRange != null) {
View Full Code Here

    private static String getRandomName() {
        return String.format("file%s.txt", Math.abs(RANDOM.nextInt()));
    }

    private String getFileContents(BlobKey blobKey) throws IOException {
        AppEngineFile file = getAppEngineFile(blobKey);
        return getFileContents(file);
    }
View Full Code Here

            .addClass(BlobserviceServeServlet.class);
    }

    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

TOP

Related Classes of com.google.appengine.api.files.AppEngineFile

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.