Can write but not read any file form file.documentsDirectory

I used the cordova-plugin-file-transfer plugin to download files to local system.

No problem for downloading, I could write into the local system

But when I try to access the files, for example to display an video downloaded in the local filesystem, my IOS device does not show any videos.

The files.toURL() correctly returns : file:///var/mobile/Containers/Data/Application/xxxxxxxxxxx/Library/Documents/u1_seq1_ac1_sp01.mp4
Looking to the container shows that the files are inside.

Even this command gives an empty video :
<videosrc=“capacitor://localhost/capacitor_file/var/mobile/Containers/Data/Application/xxxxxxxxxxx/Library/Documents/u1_seq1_ac1_sp01.mp4”/>

Any help please ? Cannot understand why I can write but no read a downloaded file to the local system.

Thanks

The file URL doesn’t look correct. Does <videosrc="file:///var/mobile/Containers/Data/Application/xxxxxxxxxxx/Library/Documents/u1_seq1_ac1_sp01.mp4"> work for you? capacitor://localhost is not the root of the device, it is the root of the application.

.ts
i use file transfer for download file in serveur :
this.fileTransfer.download(url, this.file.documentsDirectory+ name, true).then((entry) => {
let win :any =window
var workingPath = this.webView.convertFileSrc(entry.nativeURL)
console.log(workingPath)
}).catch(err => {
})

i need to read this file on local file in my application .

i user this.webView.convertFileSrc(entry.nativeURL) for convert url file :

html
< video src=“capacitor://localhost/capacitor_file/var/mobile/Containers/Data/Application/96FC7166-D484-45B5-AE40-DA3EDF2C5F34/Documents/u1_seq1_ac1_an01.mp4” style=“width: 100%; height: 200px;” controls=“true” controlsList=“nodownload” >

same code work on android:
ts
this.fileTransfer.download(url, this.file.externalDataDirectory+ name, true,).then((entry) => {
console.log(entry);
}).catch(err => {
})

html
< video src=“http://localhost/app_file/storage/emulated/0/Android/data/xxxxxxxxxxxxxx/files/u1_seq1_ac1_an01.mp4” style=“width: 100%; height: 200px;” controls=“true” controlsList=“nodownload” >

1 Like