如何上传一个缩略图

如何上传一个缩略图

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

问题描述

我刚开始使用谷歌应用程序引擎的今天,我已经爱上了终点。我做了一个很容易将存储的对象,仅仅有几个字符串值的数据存储。但是,我也希望有一个小的缩略图附和该数据存储实体。我知道如何从Android的使用的HttpServlet上传斑点。我在考虑使用数据存储实体的Blob存储图像的名字的身份证,但我不知道如何连接这两个事件,因为我的实体上传到数据存储,然后该请求后斑点。有谁知道我能得到一个图像,以某种方式连接到实体的数据存储,所以当我访问的数据存储我还记得与它相关的BLOB的Blob存储区。任何帮助将大大AP preciated!

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在GAE以满足您的不同大小的图像,还可以应用在这些图像的各种变革。

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.

我分享你一些code以及以下,所以你就会明白使用存储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)同时作为一个实体到在谷歌应用程序引擎的数据存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 01:49