Ejemplo n.º 1
0
  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;
  }
Ejemplo n.º 2
0
 public FileReadChannel openReadChannel(AppEngineFile file, boolean lock)
     throws FileNotFoundException, LockException, IOException {
   GridFilesystem gfs = getGridFilesystem();
   return new JBossFileReadChannel(gfs.getInput(file.getFullPath())); // TODO lock?
 }