From a9436b1a185b37269366ec3e2c5f337fb14cba61 Mon Sep 17 00:00:00 2001 From: klodha Date: Mon, 16 Sep 2019 15:10:54 +0530 Subject: [PATCH] ImagePicker returning same image (#306) ImagePicker returning same image Co-authored-by: Jan Piotrowski Co-authored-by: Tim Brust --- src/ios/CDVCamera.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ios/CDVCamera.m b/src/ios/CDVCamera.m index bf02ca2..1dca07c 100644 --- a/src/ios/CDVCamera.m +++ b/src/ios/CDVCamera.m @@ -398,11 +398,12 @@ static NSString* toBase64(NSData* data) { NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; NSFileManager* fileMgr = [[NSFileManager alloc] init]; // recommended by Apple (vs [NSFileManager defaultManager]) to be threadsafe NSString* filePath; - - // generate unique file name - int i = 1; + + // unique file name + NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970]; + NSNumber *timeStampObj = [NSNumber numberWithDouble: timeStamp]; do { - filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, extension]; + filePath = [NSString stringWithFormat:@"%@/%@%ld.%@", docsPath, CDV_PHOTO_PREFIX, [timeStampObj longValue], extension]; } while ([fileMgr fileExistsAtPath:filePath]); return filePath;