doushou7169 2014-07-18 05:49
浏览 68
已采纳

当DynamoDB创建表时,类java.lang.String无法转换为Long

I want to create dynamodb table using php-aws-sdk

set_time_limit(0);
error_reporting(E_ALL);

require_once 'aws/aws-autoloader.php';

use Aws\DynamoDb\DynamoDbClient;

$ddb = DynamoDbClient::factory(array(
    'key'    => $_SERVER['AWS_KEY']),
    'secret' => $_SERVER['AWS_SECRET']),
    'region' => $_SERVER['AWS_REGION'])
));

$name = 'test';

$ddb->createTable(array(
    'TableName' => $name,
    'AttributeDefinitions' => array(
        array(
            'AttributeName' => 'Event ID',
            'AttributeType' => 'S'
        )
    ),
    'KeySchema' => array(
        array(
            'AttributeName' => 'Event ID',
            'KeyType' => 'HASH'
        )
    ),
    'ProvisionedThroughput' => array(
        'ReadCapacityUnits' => $_SERVER['DDB_READ_CAPACITY_UNITS']),
        'WriteCapacityUnits' => $_SERVER['DDB_WRITE_CAPACITY_UNITS']),
    )
));

echo $name;

It is working successfully on local machine, but I have error by running script on Elasticbeanstalk

Fatal error: Uncaught Aws\DynamoDb\Exception\DynamoDbException: AWS Error Code: SerializationException, Status Code: 400, AWS Request ID: HTTCDOVSES4RU0V8IVIQFGREL7VV4KQNSO5AEMVJF66Q9ASUAAJG, AWS Error Type: client, AWS Error Message: class java.lang.String can not be converted to an Long, User-Agent: aws-sdk-php2/2.6.12 Guzzle/3.9.1 curl/7.36.0 PHP/5.5.12 thrown in /var/app/current/aws/Aws/Common/Exception/NamespaceExceptionFactory.php on line 91

  • 写回答

1条回答 默认 最新

  • duansha8764 2014-07-18 15:32
    关注

    I suspect, since the error is talking about a bad string to long (number) conversion, that your DDB_READ_CAPACITY_UNITS and DDB_WRITE_CAPACITY_UNITS values are problem being read as strings from $_SERVER. Try casting/converting them to integers.

    'ProvisionedThroughput' => array(
        'ReadCapacityUnits' => (int) $_SERVER['DDB_READ_CAPACITY_UNITS'],
        'WriteCapacityUnits' => (int) $_SERVER['DDB_WRITE_CAPACITY_UNITS'],
    )
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程