当我要在数据存储中插入 1500 字节数据时,出现错误
When I going to insert 1500 byte data at datastore , get an error
Fatal error: Uncaught exception
'google\appengine\runtime\ApplicationError' with message 'The value of
property "result" is longer than 1500 bytes.' in
/base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php:53
Stack trace: #0
/base/data/home/runtimes/php/sdk/google/appengine/runtime/ApiProxy.php(40):
google\appengine\runtime\RealApiProxy->makeSyncCall('datastore_v4',
'Commit', Object(google\appengine\datastore\v4\CommitRequest),
Object(google\appengine\datastore\v4\CommitResponse), 60) #1
/base/data/home/apps/s~apigraymatics/1.390460898442825180/public/data/GDS/Gateway/ProtoBuf.php(220):
google\appengine\runtime\ApiProxy::makeSyncCall('datastore_v4',
'Commit', Object(google\appengine\datastore\v4\CommitRequest),
Object(google\appengine\datastore\v4\CommitResponse), 60) #2
/base/data/home/apps/s~apigraymatics/1.390460898442825180/public/data/GDS/Gateway/ProtoBuf.php(101):
GDS\Gateway\ProtoBuf->execute('Commit',
Object(google\appengine\datastore\v4\CommitRequest),
Object(google\appengine\datastore\v4\Com in
/base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php
on line 53
我的代码是:
error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once 'GDS/Entity.php';
include_once 'GDS/Gateway.php';
include_once 'GDS/Store.php';
include_once 'GDS/Schema.php';
include_once 'GDS/Mapper.php';
include_once 'GDS/Gateway/ProtoBuf.php';
include_once 'GDS/Mapper/ProtoBuf.php';
$obj = new GDS\Entity();
$obj_gateway_ns1 = new GDS\Gateway\ProtoBuf(null, '<namespace>');
$obj_store = new GDS\Store('<kind>', $obj_gateway_ns1);
$obj_schema = new GDS\Schema('<kind>');
$obj_schema->addString('transaction_id',FALSE);
$obj_schema->addString('result',FALSE);
$obj_schema->addString('image',FALSE);
$insert_data = array('transaction_id'=>'sbc','result'=>'1500byte','media_type'=>'image');
$obj = $obj_store->createEntity($insert_data);
$res = $obj_store->upsert($obj);
学习GDS库解决了
$obj = new GDS\Entity();
$obj_gateway_ns1 = new GDS\Gateway\ProtoBuf(null, 'name-space');
$obj_store = new GDS\Store('<kind-name>', $obj_gateway_ns1);
$obj_schema = new GDS\Schema('<kind-name>');
$obj_schema->addString('transaction_id');
$obj_schema->addString('result',FALSE);
$obj_schema->addString('image');
$obj_store = new GDS\Store($obj_schema, $obj_gateway_ns1);
$insert_data = array('transaction_id'=>'sbc','result'=>1500byte,'media_type'=>'image');
$obj = $obj_store->createEntity($insert_data);
$res = $obj_store->upsert($obj);
感谢 Tom Walder 创建了不错的库
我遇到了类似的问题。我使用
解决了它
.set(BINARY_DATA, BlobValue.of(Blob.copyFrom(getBinaryData())).excludeFromIndexes());
而不是
.set(BINARY_DATA, Blob.copyFrom(getBinaryData()));
Fatal error: Uncaught exception 'google\appengine\runtime\ApplicationError' with message 'The value of property "result" is longer than 1500 bytes.' in /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php:53 Stack trace: #0 /base/data/home/runtimes/php/sdk/google/appengine/runtime/ApiProxy.php(40): google\appengine\runtime\RealApiProxy->makeSyncCall('datastore_v4', 'Commit', Object(google\appengine\datastore\v4\CommitRequest), Object(google\appengine\datastore\v4\CommitResponse), 60) #1 /base/data/home/apps/s~apigraymatics/1.390460898442825180/public/data/GDS/Gateway/ProtoBuf.php(220): google\appengine\runtime\ApiProxy::makeSyncCall('datastore_v4', 'Commit', Object(google\appengine\datastore\v4\CommitRequest), Object(google\appengine\datastore\v4\CommitResponse), 60) #2 /base/data/home/apps/s~apigraymatics/1.390460898442825180/public/data/GDS/Gateway/ProtoBuf.php(101): GDS\Gateway\ProtoBuf->execute('Commit', Object(google\appengine\datastore\v4\CommitRequest), Object(google\appengine\datastore\v4\Com in /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php on line 53
我的代码是:
error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once 'GDS/Entity.php';
include_once 'GDS/Gateway.php';
include_once 'GDS/Store.php';
include_once 'GDS/Schema.php';
include_once 'GDS/Mapper.php';
include_once 'GDS/Gateway/ProtoBuf.php';
include_once 'GDS/Mapper/ProtoBuf.php';
$obj = new GDS\Entity();
$obj_gateway_ns1 = new GDS\Gateway\ProtoBuf(null, '<namespace>');
$obj_store = new GDS\Store('<kind>', $obj_gateway_ns1);
$obj_schema = new GDS\Schema('<kind>');
$obj_schema->addString('transaction_id',FALSE);
$obj_schema->addString('result',FALSE);
$obj_schema->addString('image',FALSE);
$insert_data = array('transaction_id'=>'sbc','result'=>'1500byte','media_type'=>'image');
$obj = $obj_store->createEntity($insert_data);
$res = $obj_store->upsert($obj);
学习GDS库解决了
$obj = new GDS\Entity();
$obj_gateway_ns1 = new GDS\Gateway\ProtoBuf(null, 'name-space');
$obj_store = new GDS\Store('<kind-name>', $obj_gateway_ns1);
$obj_schema = new GDS\Schema('<kind-name>');
$obj_schema->addString('transaction_id');
$obj_schema->addString('result',FALSE);
$obj_schema->addString('image');
$obj_store = new GDS\Store($obj_schema, $obj_gateway_ns1);
$insert_data = array('transaction_id'=>'sbc','result'=>1500byte,'media_type'=>'image');
$obj = $obj_store->createEntity($insert_data);
$res = $obj_store->upsert($obj);
感谢 Tom Walder 创建了不错的库
我遇到了类似的问题。我使用
解决了它.set(BINARY_DATA, BlobValue.of(Blob.copyFrom(getBinaryData())).excludeFromIndexes());
而不是
.set(BINARY_DATA, Blob.copyFrom(getBinaryData()));