问题
I need to store a field that is usually over 500 characters. When using the String data type, App Engine fails and suggests to use the com.google.appengine.api.datastore.Text datatype in this case.
When doing so, the Android client fails with the following:
AndroidRuntime tag: Caused by: java.lang.IllegalArgumentException: expected primitive class, but got: class com.sample.sampleproj.sampleendpoint.model.Text at com.google.api.client.util.Data.parsePrimitiveValue(Data.java:4 53)
How can string values greater than 500 characters be stored in App Engine and supported by the Cloud Endpoint?
回答1:
There is doccumented limitation to Datastore - 500 characters for String. You can bypass it by using Text (or unindexed String, since Text is deprecated I believe). But this just covers saving/reading data from datastore.
There is undocumented limitation of 500 chars to endpoint method single param. This mean if you send some objct to the method, which after serialization takes more space than 500 chars the method will fail.
I did bypass it by using a servlet. See my question here
来源:https://stackoverflow.com/questions/15935561/cloud-endpoints-support-for-text-fields-with-more-than-500-characters