Video Upload in iOS.
Hey guys i am currently working on an iOS App where i am trying to upload Photos and Videos.
Photo upload is working fine but with Video there are some issues.
This is my code:
(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
CLCloudinary *cloudinary = [[CLCloudinary alloc] initWithUrl: @"cloudinary://869125413588945:Ocd9qDSH4B4Nj3UFsbD2wu8ZJS4@owaves"];
CLUploader* uploader = [[CLUploader alloc] init:cloudinary delegate:self];
MPMediaItem *video = [info objectForKey:UIImagePickerControllerMediaURL];
NSData *data = [NSData dataWithContentsOfFile:video];
NSString* time = _timeLabel.text;
NSString* activityCategory = _descriptionLabel.text;
UIDevice *device = [UIDevice currentDevice];
NSString *currentDeviceId = [[device identifierForVendor]UUIDString];
NSData *imageData = UIImagePNGRepresentation(image);
NSString *sourcePath = [[info objectForKey:@"UIImagePickerControllerMediaURL"]relativePath];
NSString* public_id = [NSString stringWithFormat:@"currentDeviceID:%@/activityCategory:%@/time:/%@", currentDeviceId, activityCategory, time];
[uploader upload:data options:@{ @"public_id": public_id}];
[self dismissViewControllerAnimated:YES completion:nil];
}
The problem is that when i try to upload the MPMediaItem i get this error:
*** Terminating app due to uncaught exception 'CloudinaryError', reason: 'file number be either url, path to file or NSData' ***
When i try to to typecast the video which is of type MPMediaItem to NSData and upload it the error is:
** Upload error: Invalid image file, 400 **
So how can i upload video in iOS ?
Post is closed for comments.
Comments
1 comment