我在尝试写入 Google 商店时收到 IOException
堆栈跟踪已附加
代码ia如下
FileService fileService = FileServiceFactory.getFileService();
GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
.setBucket("mybucket")
.setKey(key)
.setMimeType("text/html")
.setAcl("public-read")
.addUserMetadata("myfield1", "my field value");
try {
AppEngineFile writableFile = fileService.createNewGSFile(optionsBuilder.build());
// Open a channel for writing
boolean lockForWrite = false;
FileWriteChannel writeChannel = fileService.openWriteChannel(writableFile, lockForWrite);
PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"));
out.println(value);
out.close();
writeChannel.closeFinally();
} catch (IOException e) {
// TODO Auto-generated catch block
}
我使用的是 App Engine SDK 1.6.4
谢谢
最佳答案
这就解决了。这是典型的不耐烦的新手问题:)
我没有做的是允许我的应用程序使用谷歌云存储项目 [我错过了]。
请参阅先决条件 5,网址为
https://developers.google.com/appengine/docs/java/googlestorage/overview
关于google-app-engine - 在 servlet 中调用 createNewGSFile() 时出现 IOException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10045193/