I am developing ionic 3 app that download videos from server to the device\'s native storage . i used this URL to save file:
let externalDir = this.file.exte
If you want to access any file for native storage of mobile. Then you have to create a local server of the folder you want the access of.
https://ionicframework.com/docs/native/httpd
constructor(public file:File, public ngZone : NgZone, public httpd :Httpd){
}
startLocalServe(){
let options: HttpdOptions = {
www_root: this.file.externalDataDirectory.replace('file://',''),
port: 9000,
localhost_only: true //if you want to create multiple localhost then false
};
this.httpd.startServer(options).subscribe(url => {
console.log('Server is live',url); //Server is live http://127.0.0.0.1:9000
this.ngZone.run(()=>{
this.localServeUrl = url;
})
},error => {
console.log('Fail to start Server : ',JSON.stringify(error));
});
}
Now you will able to localserveUrl as src="http://127.0.0.0.1:9000/VideoTest1/0.mp4"
put the code startLocalServe in app.component.ts
this.platform.ready().then(()=>{
startLocalServe();
});