SOS, i need help. I did image uploading on to Amazon S3, and it's working fine, but when I rewrite this code for uploading video it's somethink wrong. Is uploading MOV file, but when i try to play it on browser from url, it's telling me: The image https... cannot be displayed because it contains error.
Here is my code:
- (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);
}
}
Pleas point me on my mistake.
Many thanks!!!
Sorted. Problem was with Image object. So I just did get video URL by :
NSURL *image = [info objectForKey:UIImagePickerControllerMediaURL];
Instead
UIImage *image = (UIImage*) [info objectForKey:UIImagePickerControllerOriginalImage];
And then pass NSData from url, so I did replace line
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
to:
NSData *imageData = [NSData dataWithContentsOfURL:image];
And tataaaaaaaa, problem sorted.