如何上传从Android应用程序文件到谷歌使用GAE应用程序引擎 [英] how to upload a file from android app to google app engine using GAE

查看:149
本文介绍了如何上传从Android应用程序文件到谷歌使用GAE应用程序引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSP文件,其中表单字段将文件上载到谷歌应用程序引擎,下面的code说明它,

I have a JSP file where the form field will uploads a file to Google app engine, the below code shows it,

 <form name="myform" id="myform" action="<%= blobstoreService.createUploadUrl("/adminupload",UploadOptions.Builder.withGoogleStorageBucketName("sampleapp")) %>" method="post" enctype="multipart/form-data">

我用JSP和Servlet写了这个程序,我需要提供Android应用程序相同的过程。如果我的GAE路径这样说 http://sampleapp.appspot.com/Uplo​​ad.jsp 我怎么能提供一个Android应用程序的形式action属性此链接。因为我没有对Android应用的想法。请建议我做什么,在Android应用程序的窗体属性提供这样从应用程序的文件可以上传

as i wrote this program with jsp and servlet i need to provide the same process in android app. If my GAE path is say like this http://sampleapp.appspot.com/Upload.jsp how can i provide this link in the form action property of an android app. As i don't have idea about android app. Kindly suggest me what to provide in android app form property so that from the app a file can be uploaded.

请告诉我,无论是在android系统的形式可能给这样的URL路径,

Kindly tell me whether it is possible in android form to give url path like this,

http://sampleapp.appspot.com/uploadservlet

,使得Android应用程序将上传文件中的GAE sampleapp.appspot.com

so that the android app will upload the file in the GAE sampleapp.appspot.com

推荐答案

是的。使用<一个href=\"http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpPost.html\"相对=nofollow> HttpPost对象通过通过你的服务器的URL在构造函数中。

Yes it is. Use an HttpPost object by passing your server URL in the constructor.

HttpPost request = new HttpPost(urlString);

只注意到您使用多部分条目。我建议你​​做诸如此类的东西在本教程一>

: Just noticed you used multipart entries. I'd suggest you do something of the sort explained in this tutorial.

当您通过URL作为你告诉Java中的目的地为您请求的参数。所以,你的请求,则必须包含您的文件数据(写在你希望的任何方式 DataOutputStream类或任何其他方式),然后必须使用它执行HttpClient的对象

When you pass the url as a parameter you're telling Java the destination for your request. So your request must then contain your file data (written in any way you wish DataOutputStream or any other way) and then you must execute it using an HttpClient object.

此外,从JSP的 GAE页面你可以看到,每一个新的&LT;形式的行动=/ handleName的方法=方法名&GT; 添加将导致:

Further, from the GAE pages on JSP you can see that every new <form action="/handleName" method="methodName"> you add will result in:

..一个新的URL,/ handleName,用新的servlet类来处理......

.. a new URL, /handleName, to be handled by a new servlet class...

这篇关于如何上传从Android应用程序文件到谷歌使用GAE应用程序引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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