Cordova file plugin not working


#1

Hi,

i have added the cordova-plugin-file to my project, but it does not seem to work. At least, when I try window.resolveLocalFileSystemURL it throws an undefined function error.
This code is inside the platform.ready event. Do I need to do anything else in ionic 2 to get this working?

I am trying this in the browser (ionic serve). The plugin states that it supports the browser as well.

Joachim


#2

Hy guys i have the same problem, but im trying it on an android device and i still get “window.resolveLocalFileSystemURL” undefined:
“Object [object global] has no method ‘resolveLocalFileSystemURL’”

Anyone knows why?


#3

I’ve been having the same problem, I get the same error “window.resolveLocalFileSystemURL is not a function” both using ionic serve, and on android. This is quite frustrating…

Any suggestions?


#4

Sorry if this is a silly question, but are you certain you have added the plugin after the platform?


#5

i have same question


#6

hey guy, i found a solution, it’s working on ionic beta 10

import {Camera, File} from "ionic-native";
declare var window;

......
window.resolveLocalFileSystemURL(imageData, (entry)=>{
       console.log(entry);
});

// entry.toInternalURL() => cdvfile://localhost/assets-library/asset/asset.JPG?id=78EE38D3-34C1-4752-983B-6E20EAFF87AD&ext=JPG

// entry.fullPath => file:///asset/asset.JPG?id=78EE38D3-34C1-4752-983B-6E20EAFF87AD&ext=JPG

but i can’t show image using that


#7

Any idea how I can use it in beta 11


#8

i belive it will work with beta 11


#9

Same problem on ionic 2.0.0-rc.0


#10

window.resolverLocalFileSystemURL can only be used once platform is ready:

platform.ready().then(() => {
    window.resolveLocalFileSystemURL(path, (dir) => {
    ...
    }
});

Don’t forget to import Platform from “ionic-angular”.


#11

Having this issue with ionic 2, has anyone properly solved this? i am using the CamerPreview plugin and am just trying to display the captured image.


#12

Hi Joachim,

You can try the following code.

File.resolveLocalFilesystemUrl(imageURI).then((fileEntry) => {

   this.imgUrl = fileEntry; // "img/bg1.jpg" ;

});

Don’t forget to import the File from the ionic-native.

Good Luck


#13

use this, import { File, Entry } from ‘@ionic-native/file’;


#14

did you ever get the resolved have the same issue on ios. works fine on android


#15

you ever resolve this facing the same issue


#16

it returns empty directory list,

  var myPath = cordova.file.externalRootDirectory; // We can use the default externalRootDirectory or use a path : file://my/custom/folder

window.resolveLocalFileSystemURL(myPath, function (dirEntry) {
	console.log(dirEntry);
     var directoryReader = dirEntry.createReader();
     directoryReader.readEntries(onSuccessCallback,onFailCallback);
});

function onSuccessCallback(entries){
  console.log( 'The magic will happen here, check out entries with');  
   console.log(entries);
}