add logic for download
This commit is contained in:
@@ -28,6 +28,26 @@ function ResultsPage() {
|
|||||||
const mediaFileRef = useRef(null);
|
const mediaFileRef = useRef(null);
|
||||||
const audioClass = response.audio_class
|
const audioClass = response.audio_class
|
||||||
const isVideo = mediaFile?.type.includes('video');
|
const isVideo = mediaFile?.type.includes('video');
|
||||||
|
|
||||||
|
const handleDownloadAll = () => {
|
||||||
|
if (audioClass === 'Music') {
|
||||||
|
extractedFiles.forEach(({ name, url }) => {
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.download = name;
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = downloadedFileURL;
|
||||||
|
link.download = mediaFile?.name ?? 'downloaded_file';
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mediaFile) {
|
if (!mediaFile) {
|
||||||
@@ -163,7 +183,7 @@ function ResultsPage() {
|
|||||||
<Button variant="outlined" color="primary" onClick={() => navigate('/upload')}>
|
<Button variant="outlined" color="primary" onClick={() => navigate('/upload')}>
|
||||||
Process Another File
|
Process Another File
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="contained" color="primary" onClick={() => navigate('/')}>Download All Files</Button>
|
<Button variant="contained" color="primary" onClick={handleDownloadAll}>Download All Files</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
Reference in New Issue
Block a user