Fix dl issue
This commit is contained in:
@@ -173,22 +173,15 @@ 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);
|
||||
|
||||
// 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;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error downloading file:', error);
|
||||
job.isDownloading = false;
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
processUpdate(item: any, binType: string) {
|
||||
|
||||
@@ -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`, {});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const environment = {
|
||||
serviceEndpoint: '/api'
|
||||
//serviceEndpoint: 'http://192.168.1.230:6080/api'
|
||||
//serviceEndpoint: '/api'
|
||||
serviceEndpoint: 'http://192.168.1.230:6080/api'
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user