Closed speti43 closed 1 year ago
Problem solved: We need to create the folder on IOS. So the final code:
const url = `${environment.streaming.baseUrl}/api/download/${this.inputItem.articleNumber}/${playlistitemid}`;
console.log('starting download', url);
const cookie = await this.auth();
const headerHttp = {
Cookie: cookie[0]
};
const pathAndFileName = this.getChapterLocalPathObject(trackOrder);
//create folder if not exists (IOS will crash without this!)
Folder.fromPath(pathAndFileName.path);
const imageDownloaderId = this.downloader.createDownload({
url,
headers: headerHttp,
path: pathAndFileName.path,
fileName: pathAndFileName.fileName
});
const response = await this.downloader.start(imageDownloaderId, (progressData: ProgressEventData) => {
console.log(`Progress : ${progressData.value}%`);
console.log(`Current Size : ${progressData.currentSize}%`);
console.log(`Total Size : ${progressData.totalSize}%`);
console.log(`Download Speed in bytes : ${progressData.speed}%`);
});
if (response.status === 'completed') {
console.log('DOWNLOAD SUCCESS');
await this.audioBookChapterDbService.updateChapterDownloaded(this.inputItem.dbId, chapterNumber, true);
console.log('DOWNLOAD COMPLETE');
return true;
} else {
console.log('ERROR DURING DOWNLOAD', response.status);
console.log(response.message.toString());
}
Code:
Filepath is correct, same code runs fine on android, file is downloaded and can be found.
Which platform(s) does your issue occur on?
IPhone 14 IOS 16.2 Andoid 13 Google Pixel 6
UPDATE:
If I don't use these parameters:
Then it works fine on IOS too.