Search code examples
fileionic-frameworkionic4

IONIC: How can i access a file in assets folder?


I have a problem when I try access a file where is project's assets folder. I can't access it.

Can you help me ?

My ts is:

var fileName = "assets/Atiye.mp4";
this.file.checkFile(this.file.applicationStorageDirectory, fileName)
.then((result) => {
alert('file exists :' + result);
},(error)=>{
alert('error : ' + JSON.stringify(error));
});

The directory is like that:

enter image description here

and error is :

enter image description here


Solution

  • Where is your TypeScript file located? I assume it is in the /app folder.

    Therefore (even if I don't think that you can directly play the video) to get to your file you should do:

    var fileName = "../assets/Atiye.mp4";