mirror of
https://github.com/DmcSDK/cordova-plugin-mediaPicker
synced 2026-04-14 00:03:04 +08:00
file path to uri
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mediapicker-dmcbig" version="2.3.5">
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mediapicker-dmcsdk" version="2.3.7">
|
||||
<name>MediaPicker</name>
|
||||
<js-module name="MediaPicker" src="www/MediaPicker.js">
|
||||
<clobbers target="window.MediaPicker"/>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user