public BlobKey getBlobKey(AppEngineFile file) {
    if (null == file) {
      throw new NullPointerException("file is null");
    }
    if (file.getFileSystem() != AppEngineFile.FileSystem.BLOBSTORE) {
      throw new IllegalArgumentException("file is not of type BLOBSTORE");
    }

    BlobKey cached = getCachedBlobKey(file);
    if (null != cached) {
      return cached;
    }

    String creationHandle = getCreationHandle(file);
    if (creationHandle == null) {
      return new BlobKey(file.getNamePart());
    }

    Entity blobInfoEntity = getBlobInfoEntity(creationHandle);
    if (blobInfoEntity == null) {
      return null;
    }

    BlobInfo blobInfo = new BlobInfoFactory().createBlobInfo(blobInfoEntity);
    return blobInfo.getBlobKey();
  }
  public AppEngineFile createNewBlobFile(String mimeType, String uploadedFileName)
      throws IOException {
    if (mimeType == null || mimeType.trim().isEmpty()) {
      mimeType = DEFAULT_MIME_TYPE;
    }

    Map<String, String> params = new TreeMap<String, String>();
    params.put(PARAMETER_MIME_TYPE, mimeType);
    if (uploadedFileName != null && !uploadedFileName.isEmpty()) {
      params.put(PARAMETER_BLOB_INFO_UPLOADED_FILE_NAME, uploadedFileName);
    }
    String filePath =
        createFilePath(
            FILESYSTEM_BLOBSTORE, null, FileServicePb.FileContentType.ContentType.RAW, params);
    AppEngineFile file = new AppEngineFile(filePath);
    if (!file.getNamePart().startsWith(CREATION_HANDLE_PREFIX)) {
      throw new RuntimeException("Expected creation handle: " + file.getFullPath());
    }
    return file;
  }
 private String getCreationHandle(AppEngineFile file) {
   String namePart = file.getNamePart();
   return (namePart.startsWith(CREATION_HANDLE_PREFIX) ? namePart : null);
 }
 public FileReadChannel openReadChannel(AppEngineFile file, boolean lock)
     throws FileNotFoundException, LockException, IOException {
   GridFilesystem gfs = getGridFilesystem();
   return new JBossFileReadChannel(gfs.getInput(file.getFullPath())); // TODO lock?
 }