0

我是新手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”,所以一切都应该没问题。

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

4

1 回答 1

2

您将客户端的终端节点设置为 S3 终端节点,而不是 DynamoDB。您将要替换:

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

具有以下内容:

[dClient setEndpoint: [AmazonEndpoints ddbEndpoint:AP_SOUTHEAST_1 secure: YES]];
于 2012-12-17T17:42:12.477 回答