Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save images and recorded files in temp directory?

I want to store pictures taken from camera and video recordings from my application in a separate folder in temporary directories for a while. And as the task is being completed, they shall be going to save into the database.

How do I save pictures taken from camera & video recording files in a separate folder in temp directories?

like image 796
alloc_iNit Avatar asked Jul 30 '11 08:07

alloc_iNit


2 Answers

You are looking for this to get tot he caches folder to store temporary files:

NSString* path = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, 
                                                      NSUserDomainMask,
                                                      YES) lastObject];

From there you can use NSFileManager to create and remove the directories you want. And store files just as to any other part of a file system. Just be aware that the system will purge the caches directory now and then.

So never rely on file remaining, nor disappearing, between restarts of your app.

like image 71
PeyloW Avatar answered Oct 05 '22 21:10

PeyloW


try this:

NSString *tmpDirectory = NSTemporaryDirectory();
NSString *tmpFile = [tmpDirectory stringByAppendingPathComponent:@"temp.txt"];
NSLog(@"Temp File:%@", tmpFile);
like image 22
Nuno Ferro Avatar answered Oct 05 '22 21:10

Nuno Ferro