我正在从iphone应用程序上传视频到Amazon S3。早些时候它上传很好,但现在突然间它已停止上传视频并崩溃了应用程序。以下是视频上传的代码
if(![ACCESS_KEY_ID isEqualToString:@"CHANGE ME"]
&& self.s3 == nil)
{
// Initial the S3 Client.
self.s3 = [[[AmazonS3Client alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY] autorelease];
self.s3.endpoint = [AmazonEndpoints s3Endpoint:US_WEST_2];
}
NSString *videoName =[NSString stringWithFormat:@"%@",titleTextField.text];
NSString *trimmedString = [videoName stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSLog(@"name %@",trimmedString);
S3PutObjectRequest *por = [[[S3PutObjectRequest alloc] initWithKey:trimmedString
inBucket:[Constants pictureBucket]] autorelease];
por.contentType = @"movie/mp4";
por.data= videoData;
S3PutObjectResponse *putObjectResponse = [self.s3 putObject:por];
这是崩溃日志
由于未捕获的异常'AmazonServiceException'而终止应用程序,原因:'(null)' * 第一次抛出调用堆栈:(0x2f370f53 0x399db6af 0xb6119 0xc39b3 0xc2f4d 0x533b9 0x5366f 0x2fd53e27 0x3a002c1d 0x3a002b8f 0x3a000c90)libc ++ abi .dylib:以AmazonServiceException类型的未捕获异常终止
答案 0 :(得分:0)
尝试设置内容长度字段并在本地声明S3客户端:
AmazonS3Client *s3 = [[AmazonS3Client alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY]; //auto release deprecated, and not necessary with local declaration
s3.endpoint = [AmazonEndpoints s3Endpoint:US_WEST_2];
//post full video
por = [[S3PutObjectRequest alloc] initWithKey:generatedString inBucket:@"dormpicbucket"];
por.contentType = @"video/mp4";
por.data = capturedMovie;
por.delegate = self;
[por setDelegate:self];
por.contentLength = [capturedMovie length];
[s3 putObject:por];
还要确保调试这个:[Constants pictureBucket]
,因为看起来你几乎明确地使用了aws文档中的示例/教程代码lol。