Package com.google.appengine.api.files.GSFileOptions

Examples of com.google.appengine.api.files.GSFileOptions.GSFileOptionsBuilder


  }

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

    GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
      .setBucket("cl-test-grid-logs")
      .setKey(blobName)
      .setAcl("public-read")
      .setContentEncoding("gzip");
    if (contentType != null) {
      optionsBuilder.setMimeType(contentType);
    }

    AppEngineFile writableFile = fileService.createNewGSFile(optionsBuilder.build());

    boolean lockForWrite = true; // We want to lock it, because we are going to call closeFinally in the end
    return fileService.openWriteChannel(writableFile, lockForWrite);
  }
View Full Code Here


  public FileWriteChannel createWritableFile(String bucketName, String fileName) throws IOException {
    return createWritableFile( bucketName, fileName,  getMimeType(fileName), DEFAULT_ACL, DEFAULT_CACHE);
  }
 
  public FileWriteChannel createWritableFile(String bucketName, String fileName, String mimeType, String permission, String cacheControl) throws IOException {
    GSFileOptionsBuilder optionsBuilder = null;
    AppEngineFile writableFile = null;
    String path = null;
   
    if(Utils.isEmpty(bucketName)||Utils.isEmpty(fileName)){
      logger.warning("bucketName : " + bucketName + " fileName : " + fileName);
      throw new IOException("Invalid Bucket or File name!");
    }
   
    optionsBuilder = new GSFileOptionsBuilder();
    optionsBuilder.setBucket(bucketName);
    optionsBuilder.setKey(fileName);
    optionsBuilder.setMimeType(mimeType);
    optionsBuilder.setAcl(permission);
    optionsBuilder.setCacheControl(cacheControl);
     
    writableFile = this.fileService.createNewGSFile(optionsBuilder.build());
    path = writableFile.getFullPath();
    writableFile = new AppEngineFile(path);
    //logger.info(path+" isWritable:"+writableFile.isWritable());
    return fileService.openWriteChannel(writableFile, true);
  }
View Full Code Here

    return new Token(
        filename, options, 0, FILES.createNewGSFile(gcsOptsToGsOpts(filename, options)));
  }

  private GSFileOptions gcsOptsToGsOpts(GcsFilename filename, GcsFileOptions options) {
    GSFileOptionsBuilder builder = new GSFileOptionsBuilder();
    builder.setBucket(filename.getBucketName());
    builder.setKey(filename.getObjectName());
    if (options.getAcl() != null) {
      builder.setAcl(options.getAcl());
    }
    if (options.getCacheControl() != null) {
      builder.setCacheControl(options.getCacheControl());
    }
    if (options.getContentDisposition() != null) {
      builder.setContentDisposition(options.getContentDisposition());
    }
    if (options.getContentEncoding() != null) {
      builder.setContentEncoding(options.getContentEncoding());
    }
    if (options.getMimeType() != null) {
      builder.setMimeType(options.getMimeType());
    }
    for (Entry<String, String> entry : options.getUserMetadata().entrySet()) {
      builder.addUserMetadata(entry.getKey(), entry.getValue());
    }
    return builder.build();
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.files.GSFileOptions.GSFileOptionsBuilder

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.