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);
}