Skip to content

Commit

Permalink
Add code to get the "realFileReader" from the FileReader overriden by…
Browse files Browse the repository at this point in the history
… the cordova-plugin-file plugin. See danielsogl/awesome-cordova-plugins#505.
  • Loading branch information
mjsorensen committed Aug 20, 2020
1 parent defd857 commit a77faf7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion projects/digitalascetic/ngx-pica/src/lib/ngx-pica.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ export class NgxPicaService {
const originCanvas: HTMLCanvasElement = document.createElement('canvas');
const ctx = originCanvas.getContext('2d');
const img = new Image();
const reader: FileReader = new FileReader();
let reader: FileReader = new FileReader();

// Is this a "real" file? In other words, is this an instance of the original `File` class (not the one overriden by cordova-plugin-file).
// If so, then we need to use the "real" FileReader (not the one overriden by cordova-plugin-file).
if (file instanceof Blob) {
const realFileReader = (reader as any)._realReader;
if (realFileReader) {
reader = realFileReader;
}
}

if (!options) {
options = {
Expand Down

0 comments on commit a77faf7

Please sign in to comment.