本文整理匯總了Java中com.google.appengine.api.files.GSFileOptions.GSFileOptionsBuilder類的典型用法代碼示例。如果您正苦於以下問題:Java GSFileOptionsBuilder類的具體用法?Java GSFileOptionsBuilder怎麽用?Java GSFileOptionsBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GSFileOptionsBuilder類屬於com.google.appengine.api.files.GSFileOptions包,在下文中一共展示了GSFileOptionsBuilder類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeSchema
import com.google.appengine.api.files.GSFileOptions.GSFileOptionsBuilder; //導入依賴的package包/類
public static void writeSchema(FileService fileService, String bucketName, String schemaKey, List<String> fieldNames, List<String> fieldTypes) throws IOException,
FileNotFoundException, FinalizationException, LockException {
GSFileOptionsBuilder schemaOptionsBuilder = new GSFileOptionsBuilder()
.setBucket(bucketName)
.setKey(schemaKey)
.setAcl("project-private");
AppEngineFile schemaFile = fileService.createNewGSFile(schemaOptionsBuilder.build());
FileWriteChannel schemaChannel = fileService.openWriteChannel(schemaFile, true);
PrintWriter schemaWriter = new PrintWriter(Channels.newWriter(schemaChannel, "UTF8"));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < fieldNames.size(); i++) {
sb.append(fieldNames.get(i) + ":" + fieldTypes.get(i));
if (i < fieldNames.size() - 1) {
sb.append(",");
}
}
schemaWriter.print(sb);
schemaWriter.close();
schemaChannel.closeFinally();
}
示例2: doGet
import com.google.appengine.api.files.GSFileOptions.GSFileOptionsBuilder; //導入依賴的package包/類
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
try {
System.out.println(newFileName());
FileService fileService = FileServiceFactory.getFileService();
GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
.setBucket("wt1-test1")
.setKey(newFileName());
AppEngineFile aef = fileService.createNewGSFile(optionsBuilder.build());
FileWriteChannel ch = fileService.openWriteChannel(aef, true);
Channels.newWriter(ch, "utf8").append("pouet").flush();
ch.closeFinally();
System.out.println("SUCCESS **************");
} catch (Exception e) {
System.out.println("FAILURE **************************");
e.printStackTrace();
}
}
示例3: FancyFileWriter
import com.google.appengine.api.files.GSFileOptions.GSFileOptionsBuilder; //導入依賴的package包/類
public FancyFileWriter(String bucketName, String fileKey) throws IOException {
lastOpenMillis = System.currentTimeMillis();
log.warning("Creating file " + bucketName + ":" + fileKey);
GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
.setBucket(bucketName)
.setKey(fileKey)
.setAcl("project-private");
logsFile = fileService.createNewGSFile(optionsBuilder.build());
init();
}
示例4: newFile
import com.google.appengine.api.files.GSFileOptions.GSFileOptionsBuilder; //導入依賴的package包/類
/**
* Create a new file on Cloud storage
*/
private AppEngineFile newFile(String name) throws IOException {
GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
.setBucket(bucketName)
.setKey(name);
return fileService.createNewGSFile(optionsBuilder.build());
}