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