Would the following conversion hold for converting from Java servlet to google app-engine cloud endpoint?
以下转换是否适用于从Java servlet转换为Google app-engine云端点?
FROM
从
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException { … }
TO
至
@ApiMethod(name = "save_blob_key", path = "save_blob_key" httpMethod = HttpMethod.POST)
public void saveBlobKey(HttpServletRequest req) throws IOException { … }
CONTEXT:
背景:
I am trying to use endpoint to process blobstore callback.
我正在尝试使用端点来处理blobstore回调。
Ref: https://developers.google.com/appengine/docs/java/blobstore/overview#Complete_Sample_App
参考:https://developers.google.com/appengine/docs/java/blobstore/overview#Complete_Sample_App
PROBLEM:
问题:
The big hickup here is that the following two lines seem to require the class HttpServletRequest
and I don't know if I may pass it to endpoint.
这里的大抱怨是以下两行似乎需要类HttpServletRequest,我不知道是否可以将它传递给端点。
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(req);
EDIT:
编辑:
I have been trying quite a lot of routes to solve this problem. My latest is combining blob servlet with endpoint api. Still I am not able to get the code to work. So the bounty goes to anyone who provides a solution or information that actually leads to a solution.
我一直在尝试很多路线来解决这个问题。我最新的是将blob servlet与端点api结合起来。我仍然无法使代码工作。因此,赏金给任何提供实际导致解决方案的解决方案或信息的人。
1 个解决方案
#1
3
You can't currently use Endpoints as a callback to the blobstore blobstoreService.createUploadUrl
. See this related answer. There is an open feature request for supporting mediaUpload, which would likely provide similar functionality to what you want. Feel free to star it to show support and get automatic updates.
您当前无法使用端点作为blobstore blobstoreService.createUploadUrl的回调。看到这个相关的答案。有一个支持mediaUpload的开放功能请求,它可能提供与您想要的功能类似的功能。随意给它加星标以显示支持并获得自动更新。
What I'd recommend would be one of two possible alternatives, depending on the amount of data you are trying to upload.
我建议的是两种可能的替代方案之一,具体取决于您尝试上传的数据量。
If you're uploading small amounts of blob data, that would fit in the datastore, use the ShortBlob
(up to 500 bytes) or Blob
(up to 1 MB) type in your Endpoints entity class. Endpoints will handle serialization on the backend and will expect (and send back) base64-encoded strings via the client libraries. This is a very simple, straightforward approach.
如果要上载适合数据存储区的少量blob数据,请在Endpoints实体类中使用ShortBlob(最多500个字节)或Blob(最多1 MB)类型。端点将处理后端的序列化,并通过客户端库期望(并发回)base64编码的字符串。这是一种非常简单,直接的方法。
If you want to provide blobs larger than 1 MB, for now, use the Google Cloud Storage JSON API. This API uses the same client library as Endpoints, so you don't have to worry about bundling another library with your application. This page has an example of inserting a blob into Google Cloud Storage with the Java client library.
如果要提供大于1 MB的blob,请立即使用Google Cloud Storage JSON API。此API使用与端点相同的客户端库,因此您不必担心将另一个库与应用程序捆绑在一起。此页面有一个使用Java客户端库将blob插入Google云端存储的示例。
#1
3
You can't currently use Endpoints as a callback to the blobstore blobstoreService.createUploadUrl
. See this related answer. There is an open feature request for supporting mediaUpload, which would likely provide similar functionality to what you want. Feel free to star it to show support and get automatic updates.
您当前无法使用端点作为blobstore blobstoreService.createUploadUrl的回调。看到这个相关的答案。有一个支持mediaUpload的开放功能请求,它可能提供与您想要的功能类似的功能。随意给它加星标以显示支持并获得自动更新。
What I'd recommend would be one of two possible alternatives, depending on the amount of data you are trying to upload.
我建议的是两种可能的替代方案之一,具体取决于您尝试上传的数据量。
If you're uploading small amounts of blob data, that would fit in the datastore, use the ShortBlob
(up to 500 bytes) or Blob
(up to 1 MB) type in your Endpoints entity class. Endpoints will handle serialization on the backend and will expect (and send back) base64-encoded strings via the client libraries. This is a very simple, straightforward approach.
如果要上载适合数据存储区的少量blob数据,请在Endpoints实体类中使用ShortBlob(最多500个字节)或Blob(最多1 MB)类型。端点将处理后端的序列化,并通过客户端库期望(并发回)base64编码的字符串。这是一种非常简单,直接的方法。
If you want to provide blobs larger than 1 MB, for now, use the Google Cloud Storage JSON API. This API uses the same client library as Endpoints, so you don't have to worry about bundling another library with your application. This page has an example of inserting a blob into Google Cloud Storage with the Java client library.
如果要提供大于1 MB的blob,请立即使用Google Cloud Storage JSON API。此API使用与端点相同的客户端库,因此您不必担心将另一个库与应用程序捆绑在一起。此页面有一个使用Java客户端库将blob插入Google云端存储的示例。