首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BlobStore -显示照片错误

BlobStore -显示照片错误
EN

Stack Overflow用户
提问于 2015-06-22 16:32:49
回答 1查看 50关注 0票数 0

我有使用GWT/GAE MySQL云的经验。但我不支持BlobStore。我得把我的项目照片加进去。为了理解BlobStore,我找到了一个例子:https://github.com/ikai/gwt-gae-image-gallery。但不起作用。我有两个问题:

1.为什么servlet“UploadServlet”返回null作为blob键:

代码语言:javascript
复制
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 {

代码语言:javascript
复制
    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。

  1. 为什么我不能展示我的照片?

在数据存储中存在:

用于数据存储的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

EN

回答 1

Stack Overflow用户

发布于 2015-07-29 01:54:29

它不能工作,因为doGet在开发模式下返回null。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30985226

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档