如何将缩略图(blob)与实体同时上传到谷歌应用引擎中的数据存储区? [英] How can I upload an thumbnail image (blob) at the same time as an Entity into a datastore in google app engine?

查看:27
本文介绍了如何将缩略图(blob)与实体同时上传到谷歌应用引擎中的数据存储区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天刚开始使用谷歌应用引擎,我已经爱上了端点.我很容易地做了一个,将一个对象存储在只有几个字符串值的数据存储中.但我还想要一个小缩略图图像与该数据存储实体一起使用.我了解如何使用 HttpServlet 从 android 上传 blob.我正在考虑使用数据存储实体的 id 作为 blobstore 中的图像名称,但我不知道如何连接这两个事件,因为我会将实体上传到数据存储,然后在该请求之后上传 blob.有谁知道我如何在 blobstore 中获取图像以某种方式连接到数据存储中的实体,因此当我访问数据存储时,我还可以调用与之关联的 blob.任何帮助将不胜感激!

I Just started using google app engine today, and I have fallen in love with endpoints. I made one very easily that will store an object in the datastore that just has a few string values. But I also want a small thumbnail image to go along with that datastore entity. I understand how to upload blobs from android using an HttpServlet. I was thinking of using the id of the datastore entity as the image's name in the blobstore, but I dont know how to connect the two events since I would upload the Entity to the datastore, and then the blob after that request. Does anyone know how I can get an image in the blobstore somehow connected to the entity in the datastore so when I access the datastore i can also recall the blob associated with it. Any help would be greatly appreciated!

谢谢,扎克

推荐答案

你可以使用 ImageService API 为您提供不同尺寸的图像,您还可以对这些图像应用各种转换.

Well you can use ImageService API in GAE to serve your images of different sizes and also you can apply various transformations on those images.

我也在下面与您分享一些代码,以便您了解我如何使用存储的 blobkey 提供图像 URL.

I am sharing you some code as well below so you will understand how I am serving the image urls using the stored blobkey.

String blobKeyString = blobKey.getKeyString();   // Returned value of blobkey when upload is done.
ImagesService services = ImagesServiceFactory.getImagesService();
ServingUrlOptions serve = ServingUrlOptions.Builder.withBlobKey(blobKey);
String imageUrl = services.getServingUrl(serve);

这篇关于如何将缩略图(blob)与实体同时上传到谷歌应用引擎中的数据存储区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆