Fix dl issue
This commit is contained in:
@@ -172,24 +172,17 @@ export class AppComponent implements OnInit {
|
||||
}
|
||||
|
||||
downloadFileFromAPI(filePath: string, filename: string, job: any) {
|
||||
job.isDownloading = true;
|
||||
this.videoProcessingService.downloadFile(`${job.data.mp4Filename}/${filename}`).subscribe({
|
||||
next: (response) => {
|
||||
const blob = new Blob([response], { type: 'video/mkv' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
job.isDownloading = false;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error downloading file:', error);
|
||||
job.isDownloading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
job.isDownloading = true;
|
||||
|
||||
// Redirection directe vers l'URL de téléchargement
|
||||
const encodedPath = encodeURIComponent(`${job.data.mp4Filename}/${filename}`);
|
||||
window.open(this.videoProcessingService.getDownloadUrl(`${job.data.mp4Filename}/${filename}`), '_blank');
|
||||
|
||||
// Simuler un délai pour l'UX, puis remettre le flag à false
|
||||
setTimeout(() => {
|
||||
job.isDownloading = false;
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
processUpdate(item: any, binType: string) {
|
||||
item.isUpdating = true;
|
||||
|
||||
@@ -35,6 +35,10 @@ export class VideoProcessingService {
|
||||
return this.http.get(`${this.apiUrl}/download?filename=${encodeURIComponent(filename)}`, { responseType: 'blob' });
|
||||
}
|
||||
|
||||
getDownloadUrl(filename: string): string {
|
||||
return `${this.apiUrl}/download?filename=${encodeURIComponent(filename)}`;
|
||||
}
|
||||
|
||||
flushQueue(): Observable<any> {
|
||||
return this.http.delete<any>(`${this.apiUrl}/jobs/completed`, {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user