I recently found an answer on stackoverflow of how to store an image inside of an App:
-(void) saveImage:(UIImage *)image withFileName:(NSString *)imageName ofType:(NSString *)extension inDirectory:(NSString *)directoryPath {
if ([[extension lowercaseString] isEqualToString:@"png"]) {
[UIImagePNGRepresentation(image) writeToFile:[directoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", imageName, @"png"]] options:NSAtomicWrite error:nil];
} else if ([[extension lowercaseString] isEqualToString:@"jpg"] || [[extension lowercaseString] isEqualToString:@"jpeg"]) {
[UIImageJPEGRepresentation(image, 1.0) writeToFile:[directoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", imageName, @"jpg"]] options:NSAtomicWrite error:nil];
} else {
ALog(@"Image Save Failed\nExtension: (%@) is not recognized, use (PNG/JPG)", extension);
}
}
How can I store a video that a user chooses from photo/video library and save it inside app? Is it any different? I’m trying to keep track of a list of videos that a user want’s to upload and when he/she ready they can upload all those videos to the app’s server.
Well, i don’t really understand your purposes, but you may try using
NSFileManagerin order to just copy a file from one URL to another:If you need to manipulate your movie in some way (i.e. cropping, changing quality), you should be using AVExportSession: