App Engine可以存儲ObjectOutputStream之類的信息嗎?Google appengine可以存儲Java對象POJO
0
A
回答
2
0
GAE確實支持Blob數據。但是有一些尺寸限制。這裏是API documentation
但另一種選擇是讓POJO的從com.google.appengine.api.datastore.Entity延伸出序列化的,GAE可以做存儲信息。如果您正在尋找一些文件或信息,請查看out。有關擴展實體的更多信息可以查詢here。
0
FileService fileService = FileServiceFactory.getFileService();
// Create a new Blob file with mime-type "text/plain"
AppEngineFile file = fileService.createNewBlobFile("text/plain");
// Open a channel to write to it
boolean lock = true;
FileWriteChannel writeChannel = fileService.openWriteChannel(file, lock);
MyObject obj = new MyObject();
obj.name="testing now";
ObjectOutputStream oos = new ObjectOutputStream(Channels.newOutputStream(writeChannel));
oos.writeObject(obj);
oos.flush();
oos.close();
// Now finalize
writeChannel.closeFinally();
// Later, read from the file using the file API
FileReadChannel readChannel = fileService.openReadChannel(file, false);
ObjectInputStream ooi = new ObjectInputStream(Channels.newInputStream(readChannel));
resp.setContentType("text/plain");
try {
resp.getWriter().print(ooi.readObject().toString());
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
這裏是將POJO保存到blobstore的代碼。 MyObject需要實現Serializable接口。
相關問題
- 1. Google Appengine雲存儲
- 2. 在Appengine中使用JSON API爲Google存儲對象設置ACL
- 3. Google Appengine數據存儲何時可以返回陳舊數據?
- 4. 我可以使用Google Appengine ndb存儲帶key_name的blob嗎?
- 5. Java存儲對象
- 6. Google存儲對象是否可以設置爲最大年齡?
- 7. 只有MySqlParameter對象可以存儲(C#)
- 8. memcached可以存儲複雜對象嗎?
- 9. Google AppEngine:瞭解數據存儲事務
- 10. Google Appengine數據存儲超時異常
- 11. Google appengine數據存儲樹結構
- 12. 在Android中存儲Google AppEngine Cookie
- 13. Java,存儲時區對象
- 14. 存儲3D對象? (Java)
- 15. 如何在appengine java應用程序中創建一個包含Google雲存儲對象的zip存檔?
- 16. 對數據存儲區中的對象數進行計數AppEngine java
- 17. 可以使用對象存儲GE來存儲圖像嗎?
- 18. Azure存儲 - NodeJS - 我可以存儲對象嗎?
- 19. 從AppEngine Java保存字節[]到Google Drive
- 20. 在AppEngine項目之外使用Google AppEngine數據存儲
- 21. Google AppEngine數據存儲區配置:可重複使用?
- 22. 從Google可讀數據AppEngine上的數據存儲與Go
- 23. Vector Object Invetory,可以存儲其他對象類型的對象?
- 24. Google AppEngine(GAE) - 完整的對象鍵
- 25. 多對象刪除Google雲存儲去
- 26. 將Firebase存儲的「陣列」對象轉換爲POJO
- 27. Oracle DBMS可以從Java存儲過程調用中返回Java對象嗎?
- 28. 在數據庫中存儲嵌套Pojo對象作爲個人對象
- 29. 如何使用java將appengine數據存儲中的對象的更新集合?
- 30. Oracle存儲過程可以返回Java中可用的對象嗎?