Skip to content

Commit

Permalink
apacheGH-420 (ios) DATA_URL is improperly prefixed
Browse files Browse the repository at this point in the history
  • Loading branch information
hazems committed Mar 3, 2019
1 parent e6609c0 commit 7034dff
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ios/CDVCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,10 @@ - (void)resultForImage:(CDVPictureOptions*)options info:(NSDictionary*)info comp
image = [self retrieveImage:info options:options];
NSData* data = [self processImage:image info:info options:options];
if (data) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:toBase64(data)];
NSString* extension = options.encodingType == EncodingTypePNG? @"image/png" : @"image/jpeg";
NSString* finalURI = [NSString stringWithFormat:@"%@%@%@%@", @"data:", extension, @";base64,", toBase64(data)];

result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:finalURI];
}
}
break;
Expand Down Expand Up @@ -701,7 +704,10 @@ - (void)imagePickerControllerReturnImageResult
break;
case DestinationTypeDataUrl:
{
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:toBase64(self.data)];
NSString* extension = self.pickerController.pictureOptions.encodingType == EncodingTypePNG ? @"image/png" : @"image/jpeg";
NSString* finalURI = [NSString stringWithFormat:@"%@%@%@%@", @"data:", extension, @";base64,", toBase64(self.data)];

result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:finalURI];
}
break;
case DestinationTypeNativeUri:
Expand Down

0 comments on commit 7034dff

Please sign in to comment.