将规则添加到S3 Bucket LifecycleConfiguration

时间:2013-02-04 14:34:01

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

我正在尝试为我的存储桶设置一个新的过期日期,但是我很难将规则添加到存储桶中。这就是我的目标:

    S3BucketLifecycleConfigurationRule *testRule = [[S3BucketLifecycleConfigurationRule alloc] initWithId:@"My Rule" andPrefix:self.newRuleTextField.text andExpirationInDays:1 andStatus:@"ENABLE"];

在此之后,我知道我需要将此规则添加到S3BucketLifecycleConfiguration实例,以便最终调用请求方法,但我无法弄清楚如何将其添加到S3BucketLifecycleConfiguration

    S3SetBucketLifecycleConfigurationRequest *setBucketLifecycleConfigurationRequest = [[S3SetBucketLifecycleConfigurationRequest alloc] initWithBucketName:self.bucketName withConfiguration:myConfig;

提前感谢yall

1 个答案:

答案 0 :(得分:1)

S3BucketLifecycleConfiguration有一个名为rules的属性,其中包含S3BucketLifecycleConfigurationRule个列表。以下应该有效:

S3BucketLifecycleConfiguration *myConfig = [S3BucketLifecycleConfiguration new];
myConfig.rules = [NSArray arrayWithObject:testRule];