- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 native 应用程序和云应用程序组件构建一个非常简单的项目。 Android 应用程序只需拍摄一张照片,然后通过 POST 将其上传到 URL。然后云应用程序将显示收到的照片,这些照片存储在 GAE 数据存储中。
目前,Android 应用似乎能够正确发送照片,并且从服务器接收到 HTTP OK。但是,当我去云应用程序上查看图像时,我没有得到图像,它看起来像是一个空白条目。
我现在不确定我的 Android 应用程序组件是否无法正确发送图像,或者云应用程序组件是否无法接收图像。我已经能够通过使用发布到上传网址的简单表单成功测试图像是否可以上传,效果非常好。
我看到的唯一一件事是,Android 代码在任何时候都不会设置“照片”标题名称并将其分配给照片的数据。但是,我似乎不知道如何设置它,而且我不相信这是唯一的问题。
我使用此页面来帮助发送文件的 Android 代码:How to send a file in Android from mobile to server using http?
这里是重要的android代码:
private class SendPhotoTask extends AsyncTask<File, Void, Void> {
@Override
protected Void doInBackground(File... photoFile) {
if (photoFile != null) {
String urlToConnect = "http://example.com/upload";
// Use a static file for testing
File photoFile2 = new File("/storage/emulated/0/Pictures/PNG_20141206_190223_-1388180531.png");
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(urlToConnect);
InputStreamEntity reqEntity = new InputStreamEntity(
new FileInputStream(photoFile2), -1);
reqEntity.setContentType("binary/octet-stream");
reqEntity.setChunked(true); // Send in multiple parts if needed
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
Log.d(DEBUG_TAG, response.getStatusLine().toString());
} catch (Exception e) {
Log.d(DEBUG_TAG, "Exception Caught: " + e);
}
}
return null;
}
}
SendPhotoTask 类的执行方式如下:
new SendPhotoTask().execute(photoFile);
这是服务器上接受我的图像的非常简单的代码(使用 webapp2 用 Python 编写):
class Gallery(BaseRequestHandler):
def post(self):
gallery_name = self.request.get('gallery_name',
DEFAULT_GALLERY_NAME)
greeting = Photo(parent=gallery_key(gallery_name))
greeting.photo = base64.b64encode(str(self.request.get('photo')))
greeting.put()
query_params = {'gallery_name': gallery_name}
self.redirect('/?' + urllib.urlencode(query_params))
我在这里做错了什么?
最佳答案
这是从 Android 应用程序到应用程序引擎 (Servlet Java) 的响应。您应该使用多部分http请求:Photo don't uploaded correctly GCS App Engine
它不是Python语言,但我希望它可以帮助你!
关于java - 如何从 Android 发送图像并在 GAE 上接收它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27339319/
在 GAE 中,我有一个应用程序将文件存储在 GAE blobstore 服务中。数据存储后,还应将其发送到未部署在 GAE 上的外部 Web 服务。我使用Java。 我的第一个想法是使用 JAX-R
我想找到一个用于验证用户、存储用户的 webapp 框架 并且具有jquery的ajax效果, 那么,你知道这个简单的框架吗? 谢谢 喜欢这个页面:http: //digu.com/reg 最佳答案
为了重新部署 GAE 应用程序,我目前必须在我用于部署的系统上安装 GAE 部署工具。虽然这个过程相对简单,但部署过程是一个手动过程,不能在防火墙后运行,并且部署工具必须安装在每台将用于更新 GAE
This链接显示 GAE 不支持开发服务器上的 cron 作业。那么我的其他选择是什么? 当用户的帐户截止日期已到时,我需要向他们发送电子邮件。 最佳答案 使用本地 cron 服务,并编写一个使用 c
我在运行 Maven GAE Plugin 的 gae:debug 目标时遇到问题.我收到的错误如下。有什么想法吗? 我用“mvn gae:debug”运行它。 [INFO] Packaging we
Google 刚刚宣布支持 App Engine 的 PHP 运行时。我有一个使用 Java 运行时开发的应用程序,它利用了 native App Engine 数据存储区。它目前用作移动客户端的后端
是否有一些前端允许管理员从 Google 应用引擎数据存储区插入、更新、删除记录以及创建修改和删除表,就像您在 mysql 上使用 phpMyAdmin 所做的那样??? 最佳答案 Google Ap
我正在以 GAE 为优势实现 PPO。以下代码是我根据OpenAI的基线实现计算GAE和返回的方式。 advantages = np.zeros_like(rewards) last_adv = 0
这是一个[python代码][1],我想知道它是否也可以用于GAE Java(当代码迁移时)。所以问题是,下面的 python 代码是否可以转换为 Java,而无需任何 Java 所没有的 pytho
当在 GAE 中收到一个 http 帖子时,我从另一个服务器下载一个 txt 文件,进行一些解析,然后返回信息。但是,当我更新这个 txt 文件并尝试通过 GAE 访问它时,似乎有延迟。这是一步一步的
当我运行 gae:run 时,它成功构建 jar 并启动服务器。但看起来服务器没有完全启动,因为我无法转到请求的页面。 当我使用 IDE(不是 maven gae 插件)和由 maven gae 插件
我知道有这样的插件可以在 vim 中调试 python:https://github.com/joonty/vdebug 我正在努力寻找调试 GAE 应用程序的方法,这可能吗?如果是这样,我应该采取什
我在 GAE 上部署了一个 webapp2 python 应用程序。有什么方法可以让我从 GAE 控制台探索源代码或更改项目文件。如果我只想更新已部署的应用程序上的单个 .py 文件而不是再次部署整个
我有一个 Google App 引擎应用程序,我希望它的工作方式有所不同,具体取决于它是在我的本地开发环境中运行(即使用 dev_appserver.py)还是在实际的 GAE 云中运行。 目前,我使
阅读 GAE NDB 数据存储的新文档: https://cloud.google.com/appengine/docs/python/ndb/modelclass#class_methods get
今天我第一次上传我的应用程序,当第一个请求进入以触发应用程序初始化时,它失败了。我已经在 Google GAE DEV 服务器上本地测试了所有内容,Google DEV 服务器和真正的 GAE 环境之
我正在使用 GAE 构建应用程序,并想为此使用 Django。哪个“补丁”更好? app-engine-patch 还是 django-gae-helpers?我指的是它们的功能和 future (其
使用 Google App Engine 标准 Python 2.7,我的dispatch.yaml 中有一个路径来指定“*/flex/*”类型的所有网址以路由到 Flex 服务。 调度.yaml调度
我需要一份关于使用 Flex+BlazeDS+Spring+GAE 的可读教程(在 GAE 数据存储中存储多个表)。有这样的吗? 最佳答案 你必须一步一步来: http://www.springsou
我们要重复 spring-boot-sample-gae 的指令一步一步,但我们仍然无法创建 WAR 文件,并出现以下错误消息: [错误] 无法在项目 gae-demo 上执行目标:无法解析项目 or
我是一名优秀的程序员,十分优秀!