首先让我说,我是新的IOS /的Xcode以及AWS。
我创建一个AWS S3存储写入数据的应用程序。 创建桶,并把对象美国标准区域时,应用程序的工作原理。 但是,当我改变该地区的新加坡,应用程序成功地创建了斗 - 但是,我不能把物体插入水桶和AWS不会产生任何形式的错误或异常。
这是有问题的代码。 在createBucket方法的注释的代码创建成功在新加坡桶。 该processGrandCentralDispatchUpload方法是美国标准的区域工作,但并没有把对象我的新加坡桶。
- (void)createBucket
{
// Create the bucket.
@try {
//S3Region *region = [[S3Region alloc] initWithStringValue:kS3RegionAPSoutheast1];
//S3CreateBucketRequest *createBucketRequest = [[S3CreateBucketRequest alloc] initWithName:[Constants S3Bucket] andRegion:region];
S3CreateBucketRequest *createBucketRequest = [[S3CreateBucketRequest alloc] initWithName:[Constants S3Bucket]];
S3CreateBucketResponse *createBucketResponse = [self.s3 createBucket:createBucketRequest];
NSLog(@"create bucket response: %@", createBucketResponse.error);
if(createBucketResponse.error != nil)
{
NSLog(@"Error: %@", createBucketResponse.error);
}
}
@catch (AmazonServiceException* asex) {
NSLog(@"putObject - AmazonServiceException - %@", asex);
}
@catch (AmazonClientException* acex) {
NSLog(@"putObject - AmazonClientException - %@", acex);
}
}
- (void)processGrandCentralDispatchUpload:(NSData *)jsonData withTimestamp:(int)timestamp
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
UserData * user = [[[DataStore defaultStore] user] objectAtIndex:0];
NSString * dateKeyComponent = [self putRequestDateComponent:timestamp];
objectName = [NSString stringWithFormat:@"%@/%@/%@", user.email, user.uniqueIdentifier, dateKeyComponent];
S3PutObjectRequest *putObjectRequest = [[S3PutObjectRequest alloc] initWithKey:objectName
inBucket:[Constants S3Bucket]];
putObjectRequest.contentType = @"data/json";
putObjectRequest.data = jsonData;
// Put the image data into the specified s3 bucket and object.
@try {
S3PutObjectResponse *putObjectResponse = [self.s3 putObject:putObjectRequest];
dispatch_async(dispatch_get_main_queue(), ^{
if(putObjectResponse.error != nil)
{
NSLog(@"Error: %@", putObjectResponse.error);
[self showAlertMessage:[putObjectResponse.error.userInfo objectForKey:@"message"] withTitle:@"Upload Error"];
}
else
{
//[self showAlertMessage:@"The data was successfully uploaded." withTitle:@"Upload Completed"];
}
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
});
}
@catch (AmazonServiceException* asex) {
NSLog(@"putObject - AmazonServiceException - %@", asex);
}
@catch (AmazonClientException* acex) {
NSLog(@"putObject - AmazonClientException - %@", acex);
}
});
}