diff --git a/package.json b/package.json index 0289cbd..f748a1f 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "cordova-plugin-mediapicker-dmcbig", - "version": "2.3.5", + "name": "cordova-plugin-mediapicker-dmcsdk", + "version": "2.3.7", "description": "android ios mediaPicker support selection of multiple image and video", "cordova": { - "id": "cordova-plugin-mediapicker-dmcbig", + "id": "cordova-plugin-mediapicker-dmcsdk", "platforms": [ "android", "ios" diff --git a/plugin.xml b/plugin.xml index 55146f3..96404be 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,6 +1,6 @@ - + MediaPicker diff --git a/src/android/MediaPicker.java b/src/android/MediaPicker.java index aa20420..5a492f0 100644 --- a/src/android/MediaPicker.java +++ b/src/android/MediaPicker.java @@ -163,7 +163,7 @@ public class MediaPicker extends CordovaPlugin { for(Media media:select){ JSONObject object=new JSONObject(); object.put("path",media.path); - object.put("uri",Uri.parse(media.path)); + object.put("uri",Uri.fromFile(new File(media.path)));//Uri.fromFile(file).toString() || [NSURL fileURLWithPath:filePath] absoluteString] object.put("size",media.size); object.put("name",media.name); object.put("index",index); @@ -237,6 +237,7 @@ public class MediaPicker extends CordovaPlugin { if(quality<100) { File file = compressImage(path, quality); jsonObject.put("path", file.getPath()); + jsonObject.put("uri", Uri.fromFile(file.getPath())); jsonObject.put("size", file.length()); jsonObject.put("name", file.getName()); callbackContext.success(jsonObject); diff --git a/src/ios/MediaPicker.m b/src/ios/MediaPicker.m index 453f11b..1d161b1 100644 --- a/src/ios/MediaPicker.m +++ b/src/ios/MediaPicker.m @@ -72,15 +72,15 @@ [[PHImageManager defaultManager] requestImageDataForAsset:asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) { NSString *filename=[asset valueForKey:@"filename"]; NSString *fullpath=[NSString stringWithFormat:@"%@/%@%@", dmcPickerPath,[[NSProcessInfo processInfo] globallyUniqueString], filename]; - NSNumber *size=[NSNumber numberWithLong:imageData.length]; + NSNumber *size=[NSNumber numberWithLong:imageData.length]; NSError *error = nil; if (![imageData writeToFile:fullpath options:NSAtomicWrite error:&error]) { NSLog(@"%@", [error localizedDescription]); [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]] callbackId:callbackId]; } else { - - NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:fullpath,@"path",@"image",@"mediaType",size,@"size",[NSNumber numberWithInt:index],@"index", nil]; + + NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:fullpath,@"path",[NSURL fileURLWithPath:fullpath] absoluteString],@"uri",@"image",@"mediaType",size,@"size",[NSNumber numberWithInt:index],@"index", nil]; [aListArray addObject:dict]; if([aListArray count]==[selectArray count]){ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:aListArray] callbackId:callbackId]; @@ -88,26 +88,26 @@ } }]; -} +} + +- (void)getExifForKey:(CDVInvokedUrlCommand*)command +{ + callbackId=command.callbackId; + NSString *path= [command.arguments objectAtIndex: 0]; + NSString *key = [command.arguments objectAtIndex: 1]; + + NSData *imageData = [NSData dataWithContentsOfFile:path]; + //UIImage * image= [[UIImage alloc] initWithContentsOfFile:[options objectForKey:@"path"] ]; + CGImageSourceRef imageRef=CGImageSourceCreateWithData((CFDataRef)imageData, NULL); + + CFDictionaryRef imageInfo = CGImageSourceCopyPropertiesAtIndex(imageRef, 0,NULL); + + NSDictionary *nsdic = (__bridge_transfer NSDictionary*)imageInfo; + NSString* orientation=[nsdic objectForKey:key]; + + [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:orientation] callbackId:callbackId]; + -- (void)getExifForKey:(CDVInvokedUrlCommand*)command -{ - callbackId=command.callbackId; - NSString *path= [command.arguments objectAtIndex: 0]; - NSString *key = [command.arguments objectAtIndex: 1]; - - NSData *imageData = [NSData dataWithContentsOfFile:path]; - //UIImage * image= [[UIImage alloc] initWithContentsOfFile:[options objectForKey:@"path"] ]; - CGImageSourceRef imageRef=CGImageSourceCreateWithData((CFDataRef)imageData, NULL); - - CFDictionaryRef imageInfo = CGImageSourceCopyPropertiesAtIndex(imageRef, 0,NULL); - - NSDictionary *nsdic = (__bridge_transfer NSDictionary*)imageInfo; - NSString* orientation=[nsdic objectForKey:key]; - - [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:orientation] callbackId:callbackId]; - - } @@ -120,7 +120,7 @@ NSString *fullpath=[NSString stringWithFormat:@"%@/%@", dmcPickerPath,filename]; NSLog(@"%@", urlAsset.URL); - NSData *data = [NSData dataWithContentsOfURL:urlAsset.URL options:NSDataReadingUncached error:nil]; + NSData *data = [NSData dataWithContentsOfURL:urlAsset.URL options:NSDataReadingUncached error:nil]; NSNumber* size=[NSNumber numberWithLong: data.length]; NSError *error = nil; @@ -129,7 +129,7 @@ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]] callbackId:callbackId]; } else { - NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:fullpath,@"path",size,@"size",@"video",@"mediaType" ,[NSNumber numberWithInt:index],@"index", nil]; + NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:fullpath,@"path",[NSURL fileURLWithPath:fullpath] absoluteString],@"uri",size,@"size",@"video",@"mediaType" ,[NSNumber numberWithInt:index],@"index", nil]; [aListArray addObject:dict]; if([aListArray count]==[selectArray count]){ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:aListArray] callbackId:callbackId]; @@ -167,7 +167,7 @@ NSLog(@"completed!"); NSString *compressCompletedjs = [NSString stringWithFormat:@"MediaPicker.compressEvent('%@',%i)", @"completed",index]; [self.commandDelegate evalJs:compressCompletedjs]; - NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:fullpath,@"path",@"video",@"mediaType" ,[NSNumber numberWithInt:index],@"index", nil]; + NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:fullpath,@"path",[NSURL fileURLWithPath:fullpath] absoluteString],@"uri",@"video",@"mediaType" ,[NSNumber numberWithInt:index],@"index", nil]; [aListArray addObject:dict]; if([aListArray count]==[selectArray count]){ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:aListArray] callbackId:callbackId]; @@ -283,6 +283,7 @@ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]] callbackId:callbackId]; } else { [options setObject:fullpath forKey:@"path"]; + [options setObject:[NSURL fileURLWithPath:fullpath] absoluteString] forKey:@"uri"]; [options setObject:size forKey:@"size"]; [options setObject:filename forKey:@"name"]; [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:options] callbackId:callbackId];