我有使用GWT/GAE MySQL云的经验。但我不支持BlobStore。我得把我的项目照片加进去。为了理解BlobStore,我找到了一个例子:https://github.com/ikai/gwt-gae-image-gallery。但不起作用。我有两个问题:
1.为什么servlet“UploadServlet”返回null作为blob键:
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
// Take uploaded image
Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(req);
System.out.println("UPL.SERV.key size=" + blobs.size());
List<BlobKey> blobKey = blobs.get("image");
ImagesService imagesService = ImagesServiceFactory.getImagesService();
String imageUrl = imagesService.getServingUrl(ServingUrlOptions.Builder.withBlobKey(blobKey.get(0))).trim();
// Uploaded image object: key, servingUrl,createdAt, ownerId
Entity uploadedImage = new Entity("UploadedImage");
uploadedImage.setProperty("blobKey", blobKey.get(0).getKeyString().trim());
uploadedImage.setProperty(UploadedImage.CREATED_AT, new Date());
uploadedImage.setProperty(UploadedImage.OWNER_ID, "anna");
// Highly unlikely we'll ever search on this property
uploadedImage.setUnindexedProperty(UploadedImage.SERVING_URL, imageUrl);
System.out.println("UPL.SERV-5- Z datastore key=" + keyString);
res.sendRedirect("/upload?uploadedImageKey=" + keyString);
}key=aglub19hcHBfaWRyGgsSDVVwbG9hZGVkSW1hZ2UYgICAgICA4ggM @ doPost doGet(HttpServletRequest req,HttpServletResponse resp)抛出ServletException,IOException {
System.out.println("UPL.SERV-6- req="+req.getParameter("uploadedImageKey"));
String uploadedImageKey = req.getParameter("uploadedImageKey").trim();
resp.setHeader("Content-Type", "text/html");
// This is a bit hacky, but it'll work. We'll use this key in an Async
// service to
// fetch the image and image information
System.out.println("UPL.SERV-7- resp="+uploadedImageKey);
resp.getWriter().println(uploadedImageKey);
}获得: UPL.SERV-6- req=aglub19hcHBfaWRyGgsSDVVwbG9hZGVkSW1hZ2UYgICAgICA4ggM,并将应答发送到“UploadPhoto”:UPL.SERV-7- resp=aglub19hcHBfaWRyGgsSDVVwbG9hZGVkSW1hZ2UYgICAgICA4ggM。
“UploadPhoto获得null。
在数据存储中存在:
用于数据存储的UPL.SERV-3集
UPL.SERV-3-BLOBKY=7 7cvGUXW_q9Q9QTEArWv3LA
UPL.SERV-3-KEY=UploadedImage(无id-尚未)
UPL.SERV-3-所有者=anna
UPL.SERV-3-url=q9Q9QTEArWv3LA
UPL.SERV-4-放置到数据存储
当创建了“ImageOverlay”小部件时,我得到:
7cvGUXW_q9Q9QTEArWv3LA=s200:1 GET q9Q9QTEArWv3LA=s200 net::ERR_ADDRESS_INVALID
发布于 2015-07-29 01:54:29
它不能工作,因为doGet在开发模式下返回null。
https://stackoverflow.com/questions/30985226
复制相似问题