Here was what I was using that took too long:

private byte[] getImageBytes(BlobData blobData) {
    if (blobData == null) {
      return null;
    }

    BlobKey blobKey = new BlobKey(blobData.getKey());
    if (blobKey == null) {
      return null;
    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    long filesize = blobData.getSize();
    int chunkSize = 1024;
    long offset = 0;
    while (offset < filesize) {

      long limit = offset + chunkSize - 1;
      if (filesize < limit) {
        limit = filesize - 1;
      }

      log.info("offset=" + offset + " limit=" + limit + " size=" + filesize);

      byte[] b = null;
      try {
        b = blobstoreService.fetchData(blobKey, offset, limit);
      } catch (Exception e) {
        if (e.toString().toLowerCase().contains("deadline") == false) {
          System.out.println("Ga_Service_Image.getImageBytes(): doing 
workaround " + e.toString());
          workaround(out, blobKey, offset, filesize);
        } else {
          log.severe("getImageBytes(): Error: Hit a deadline I think. " + 
e.toString());
          e.printStackTrace();
        }
        break;
      }
      try {
        if (b != null) {
          out.write(b);
        }
      } catch (IOException e) {
        e.printStackTrace();
        return null;
      }

      offset += chunkSize;
      if (offset > filesize) {
        offset = filesize;
      }
    }

    byte[] filebytes = out.toByteArray();

    log.info("getImageBytes(): filebytes size: " + filebytes.length + " 
blobData.size=" + blobData.getSize());

    return filebytes;
  }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to