My downloaded file are all just 15kb?


#1

When the download has happened and the file is now on the servers public folder ready to download the following code is activated:

                                filename = video.details.fileName;
                                let url = video.details.fileLocation;
                                let filename = url.substring(url.lastIndexOf("/") + 1).split("?")[0];
                                let xhr = new XMLHttpRequest();
                                xhr.responseType = 'blob';
                                xhr.onload = function() {
                                    var a = document.createElement('a');
                                    a.href = window.URL.createObjectURL(xhr.response); // xhr.response is a blob
                                    a.download = filename; // Set the file name.
                                    a.style.display = 'none';
                                    document.body.appendChild(a);
                                    a.click();
                                };
                                xhr.open('GET', url);
                                xhr.send();

The file does download but it is only 15kb and will not play. The files in the public folder are the correct size and will play. Please help if you can!

I also tried:

                                var downloadLink = document.createElement('a'); 
                                downloadLink.href = url; 
                                downloadLink.download = filename; 
                                document.body.appendChild(downloadLink); 
                                downloadLink.click();