求救,我需要帮助。我将图像上传到 Amazon S3,它工作正常,但是当我重写此代码以上传视频时,它有些错误。正在上传 MOV 文件,但是当我尝试从 url 在浏览器上播放它时,它告诉我:图像 https... 无法显示,因为它包含错误。
这是我的代码:
- (BOOL) startMediaBrowserFromViewController: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate{
// Get image picker
UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
mediaUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
mediaUI.allowsEditing = YES;
mediaUI.delegate = delegate;
// Display movie files
[controller presentModalViewController:mediaUI animated:YES ];
- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {
[self dismissModalViewControllerAnimated:YES];
UIImage *image = (UIImage*) [info objectForKey:UIImagePickerControllerOriginalImage];
fileName = "anyName.MOV";
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
@try {
S3PutObjectRequest *por = [[S3PutObjectRequest alloc] initWithKey:fileName inBucket:MY_BUCKET];
por.contentType = @"movie/mov";
por.cannedACL = [S3CannedACL publicRead];
por.data = imageData;
[s3 putObject:por];
}
@catch (AmazonClientException *exception) {
NSLog(@"exception %@", exception);
}
}
请指出我的错误。
非常感谢!!!