Tag: 谷歌云的端点

响应头GAE端点

是否可以控制在Google App Engine的终端中创建响应? 我知道GAE 可以将Request对象注入某些API方法 提前致谢。

将Android应用程序连接到Google Cloud Endpoints时出错:无法找到课程

我已经使用Google Cloud Endpoints构建了一个API,我正在尝试连接到它编写Android应用程序。 我按照以下教程: https://developers.google.com/appengine/docs/java/endpoints/consume_android 所以,我在我的“src”文件夹中添加了jar的内容,我将列出的库复制到lib并添加了代码。 当我尝试启动应用程序时,它崩溃了以下错误: 02-26 12:19:52.874: E/dalvikvm(17558): Could not find class ‘com.google.api.services.utenteendpoint.Utenteendpoint$Builder’, referenced from method com.example.androidgcetest.MainActivity.onCreate 02-26 12:19:53.004: E/AndroidRuntime(17558): FATAL EXCEPTION: main 02-26 12:19:53.004: E/AndroidRuntime(17558): java.lang.NoClassDefFoundError: com.google.api.services.utenteendpoint.Utenteendpoint$Builder 02-26 12:19:53.004: E/AndroidRuntime(17558): at com.example.androidgcetest.MainActivity.onCreate(MainActivity.java:22) 02-26 12:19:53.004: E/AndroidRuntime(17558): at android.app.Activity.performCreate(Activity.java:4465) 02-26 12:19:53.004: E/AndroidRuntime(17558): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 02-26 12:19:53.004: E/AndroidRuntime(17558): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931) 02-26 12:19:53.004: E/AndroidRuntime(17558): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992) […]

为什么Google Cloud Endpoints不支持简单对象返回类型?

我的大多数方法返回字符串,整数,布尔值等等,我敢打赌99%的开发人员都有,确保我们有时会返回复杂的对象,数组等,但大多数时候会更简单一些。 为什么Cloud Endpoints不支持此function? 谢谢!

通过appengine将文件上传到Google云端存储

我正在尝试将文件上传到Google云端存储。 我的Servlet代码是 public class UploadFile extends HttpServlet { private final String BUCKET = “XXXXXXXXX”; private boolean isMultipart; private String filePath; private int maxFileSize = 5 * 1024 * 1024; private int maxMemSize = 5 * 1024 * 1024; private File file ; public void init( ){ // Get the file location where it would be […]

Google Endpoints – Android GoogleAuthIOException Tic Tac Toe – 删除了clientIds

我下载了Google Endpoints Tic Tac Toe示例 – Java中的服务器代码。 为了快速运行它,我从API定义中删除了clientIds,因此我可以很快看到它在API Explorer中运行: @Api(name = “tictactoe”, version = “v1”) public class ScoresV1 { … 我可以使用API​​资源管理器运行以下方法,打开OAuth并使用我的gmail accoumnt进行身份validation。 我可以在调试器中看到“user”对象设置为该帐户: @ApiMethod(name = “scores.list”) @SuppressWarnings(“unchecked”) public List list(@Nullable @Named(“limit”) String limit, @Nullable @Named(“order”) String order, User user) throws OAuthRequestException, IOException { … 然后我继续生成Android客户端(仍然删除了clientIds)。 我还下载了官方Android应用程序来获取UI类和res文件(帐户选择器和游戏界面)。 这就是我被困住的地方。 在真正的Android设备上运行时,TictactoeActivity中的以下代码抛出了GoogleAuthIOException: @Override protected ScoreCollection doInBackground(Void… unused) { ScoreCollection […]

将图像从Android客户端发送到AppEngine Cloud Endpoint

我正在使用AppEngine后端开发Android应用程序。 我正在使用Java中的Google Cloud Endpoints创建服务器部分。 我的问题是我无法从客户端向服务器发送位图。 我使用了这个问题的答案,但即使客户端部分似乎没有任何问题,服务器部分也根本不接收数据。 我也认为这个解决方案可能有点复杂,它可能会以不同的,更简单的方式工作,但这是我第一次实现服务器并第一次向它发送图片,所以我接受任何有关此的好建议。 谢谢! 这是我的代码: String boundary = Long.toHexString(System.currentTimeMillis()); // Just generate some unique random value. String CRLF = “\r\n”; // Line separator required by multipart/form-data. String charset = “UTF-8”; HttpURLConnection connection = (HttpURLConnection) new URL(“https://path_to_my_app/_ah/api/registration/v1/uploadImage”).openConnection(); connection.setDoOutput(true); connection.setReadTimeout(60000); connection.setRequestMethod(“POST”); connection.setRequestProperty(“Content-Type”, “multipart/form-data; boundary=” + boundary); PrintWriter writer = null; try { OutputStream […]

Gradle失败:找不到支持的Gradle DSL方法:’exclude()’

我正在尝试将我最近编码的Google端点(Python)中的类包含到我的Android项目(Android Studio – 最新版,Gradle)中。 服务器端都经过测试和运行。 我不习惯Gradle,因此我正在关注Google Developers的文档。 将src下的build.gradle文件(按文档指示)更改为: 的build.gradle: buildscript { repositories { mavenCentral() } dependencies { classpath ‘com.android.tools.build:gradle:0.9.+’ } } apply plugin: ‘android’ repositories { maven { url ‘http://google-api-client-libraries.appspot.com/mavenrepo’ } mavenCentral() mavenLocal() } android { compileSdkVersion 19 buildToolsVersion “19.0.2” defaultConfig { minSdkVersion 17 targetSdkVersion 19 versionCode 1 versionName “1.0” } buildTypes { release { […]

此API不支持解析表单编码输入

我试图将数据提交到端点,但它说数据大小太大,所以我将方法更改为POST并收到错误: This API does not support parsing form-encoded input. 接下来我将类型更改为application / json,仍然使用post,现在我得到: { “error”: { “errors”: [ { “domain”: “global”, “reason”: “parseError”, “message”: “Parse Error” } ], “code”: 400, “message”: “Parse Error” } } 将大量数据(即2730字节)发布到端点并让它正确处理的最佳方法是什么? 在我的情况下,有问题的字段是Text类型,因为我超过500个字符限制,app引擎要保存在String中。 此外,与许多事情一样,这在我的本地计算机上运行良好,它只在实时应用程序引擎实例上提供此错误。 谢谢!

将servlet架构转换为app-engine端点架构

以下转换是否适用于从Java servlet转换为Google app-engine云端点? 从 public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { … } 至 @ApiMethod(name = “save_blob_key”, path = “save_blob_key” httpMethod = HttpMethod.POST) public void saveBlobKey(HttpServletRequest req) throws IOException { … } 背景: 我正在尝试使用端点来处理blobstore回调。 参考: https : //developers.google.com/appengine/docs/java/blobstore/overview#Complete_Sample_App 问题: 这里的大抱怨是以下两行似乎需要类HttpServletRequest ,我不知道是否可以将它传递给端点。 BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); Map<String, List> blobs = blobstoreService.getUploads(req); 编辑: 我一直在尝试很多路线来解决这个问题。 […]

将装箱原语列表传递给Google Cloud Endpoint

我正在努力将Lists作为Google Cloud Endpoints的方法参数。 文件说明了这一点 支持的参数类型如下: java.util.Collection参数类型 我试着这样做,但它只是不起作用。 基本端点方法: @ApiMethod(name = “testMethod”, httpMethod = HttpMethod.POST) public void testMethod(@Named(“longList”) List longList) { for (Long aLong : longList) { if (aLong < 5) { throw new IllegalArgumentException("You can't do it"); } } } 当我使用API​​ Exploler执行此方法时,生成的URL为: POST http://localhost:8080/_ah/api/billEndpoint/v1/testMethod?longList=5&longList=6 并且该方法正确执行。 但是当使用Android库时,url会更改为: http://APP_ENGINE_BACKEND:8080/_ah/api/billEndpoint/v1/testMethod/5,6 并且端点返回404代码。 可以将List作为方法参数,如果它是我做错了吗?