DynamoDB - 项目不上传

时间:2012-12-17 08:17:02

标签: objective-c ios amazon-web-services amazon-dynamodb

我是DynamoDB的新手,我想用它来存储我将与S3对象匹配的关键字符串。这是我上传字符串的代码:

AmazonCredentials *amazonCreds = [[AmazonCredentials alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey: SECRET_KEY];

AmazonDynamoDBClient *dClient = [[AmazonDynamoDBClient alloc] initWithCredentials: amazonCreds];

[dClient setEndpoint: [AmazonEndpoints s3Endpoint:AP_SOUTHEAST_1 secure: YES]];

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
                          [[DynamoDBAttributeValue alloc] initWithS: req.key],
                          @"QuoteKey",
                          nil];

DynamoDBPutItemRequest *dReq = [[DynamoDBPutItemRequest alloc] initWithTableName:@"TestQuotesTable" andItem: [dict mutableCopy]];
DynamoDBPutItemResponse *dRes = [dClient putItem: dReq];

但是当我进入控制台并进入表格时,该项目未上传....我的代码是否有问题。当我第一次在DynamoDB创建我的表时,默认的键/属性名称是“QuoteKey”,所以一切都应该没问题。

我的代码有什么问题?感谢

1 个答案:

答案 0 :(得分:2)

您正在将客户端的端点设置为S3端点,而不是DynamoDB。你想要替换:

[dClient setEndpoint: [AmazonEndpoints s3Endpoint:AP_SOUTHEAST_1 secure: YES]];

以下内容:

[dClient setEndpoint: [AmazonEndpoints ddbEndpoint:AP_SOUTHEAST_1 secure: YES]];