简体   繁体   English

GAE:如何通过未使用Java部署在GAE上的外部Web服务来访问存储在GAE Blobstore中的数据/文件?

[英]GAE: How is it possible to access data/files that are stored in the GAE Blobstore by an external Web Service that is not deployed on GAE using Java

Within GAE, I have an application that stores files in the GAE blobstore service. 在GAE中,我有一个应用程序,用于在GAE blobstore服务中存储文件。 After the data is stored, it should also be send to an external Web Service not deployed on GAE. 存储数据后,还应将其发送到未部署在GAE上的外部Web服务。 I use Java. 我用的是Java。

My first idea was to use JAX-RPC (the Java API for XML-based RPC) and SAAJ (SOAP with Attachments API for Java) as described in http://www.ibm.com/developerworks/xml/library/x-tippass/ but I was not able to deploy the Axis2 framework on GAE because I got socket exceptions (not allowed in GAE). 我的第一个想法是使用JAX-RPC(基于XML的Java的Java API)和SAAJ(SOAP with Attachments API for Java),如http://www.ibm.com/developerworks/xml/library/x-中所述。 tippass /但是我无法在GAE上部署Axis2框架,因为我有套接字异常(在GAE中不允许)。 The idea was to push the data to the external web service. 我们的想法是将数据推送到外部Web服务。

In my second try, I wanted to pull the data from GAE, which means to access the file directly in the Blobstore by the external Web Service. 在我的第二次尝试中,我想从GAE中提取数据,这意味着通过外部Web服务直接在Blobstore中访问该文件。 In the Admin console of GAE, it is possible to download the blobs. 在GAE的管理控制台中,可以下载blob。 Therefore, I thought, I can do the same with my external Web Service by passing the key of the blob to the external Web Service to use java.net.URL to fetch my file, similarly described describe here: http://code.google.com/intl/de-DE/appengine/docs/java/urlfetch/overview.html . 因此,我想,我可以通过将blob的密钥传递给外部Web服务来使用java.net.URL获取我的文件来对我的外部Web服务执行相同的操作,类似于此处描述: http:// code。 google.com/intl/de-DE/appengine/docs/java/urlfetch/overview.html This link looks like this: 此链接如下所示:

String blobFileUrl = "https://appengine.google.com/blobstore/download?app_id=s~gae_app&key=" + gaeBlobKey;

However, it did not work because the webservice/www-user needs to be authenticated and authorized to access the file. 但是,它不起作用,因为需要对webservice / www-user进行身份验证并授权其访问该文件。 As far as I know, Google does not provide a Java API to login in GAE from an external web service. 据我所知,Google没有提供Java API来从外部Web服务登录GAE。

Is it possible to access blobs/data of GAE with an external Web Service, which is not deployed on GAE, using Java? 是否可以使用外部Web服务访问GAE的blob /数据,而外部Web服务未使用Java部署在GAE上? If so, how is it possible? 如果是这样,怎么可能?

You can create a servlet in your GAE App that simply serves a blob given a blob key. 您可以在GAE应用程序中创建一个servlet,它只是为blob键提供blob。

The url would be something like this: 网址将是这样的:

http://appid.appspot.com/blobserve?blobKey=3asdfg324gdasdf http://appid.appspot.com/blobserve?blobKey=3asdfg324gdasdf

and your servlet would look like this: 你的servlet看起来像这样:

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException {
    BlobKey blobKey = new BlobKey(req.getParameter("blobKey"));
    blobstoreService.serve(blobKey, res);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM