Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download Functionality Failing with "Internet Connection Error" #146

Open
Brielle28 opened this issue Dec 1, 2024 · 0 comments
Open

Download Functionality Failing with "Internet Connection Error" #146

Brielle28 opened this issue Dec 1, 2024 · 0 comments

Comments

@Brielle28
Copy link

Bug Report: Download Functionality Not Working (Internet Connection Error)

Description:

I am facing an issue with the download functionality in the application. When I try to download a recording, I receive an "internet connection error" in the download history, and the download does not proceed as expected.

Steps to Reproduce:

  1. Download Function:
    Here’s the downloadRecording function that I am using to handle the download:

    const downloadRecording = (recordingUrl, fileName) => {
        const a = document.createElement("a");
        a.href = recordingUrl;
        a.download = `${fileName}.mp3`; // Use the provided file name
        a.click(); // Trigger the download
    };
  2. Using the Download Function:
    In the component where the user can download a recording, I’m using the following code to find the selected recording and call the downloadRecording function:

    const { downloadRecording, recordings } = useContext(UserContext);
    
    const selectedRecording = recordings.find(
        (recording) => recording.id === audioId
    );
    
    action.icon === "Download" ? (
        <div
            onClick={() => {
                // Only download if a specific recording is found
                if (selectedRecording) {
                    console.log("Downloading:", {
                        url: selectedRecording.url,
                        name: selectedRecording.name,
                    });
                    downloadRecording(
                        selectedRecording.url,
                        selectedRecording.name
                    );
                } else {
                    console.error("No recording found for ID:", audioId);
                    alert("Recording not found. Please try again.");
                }
            }}
            style={{ cursor: "pointer" }}
        >
            {Content}
        </div>
    );

Expected Behavior:

The recording should download successfully when the "Download" option is clicked, with the file being saved as fileName.mp3.

Actual Behavior:

The download fails with an "internet connection error" message in the download history, and the download does not proceed.

Troubleshooting Steps Taken:

  1. I’ve logged the selectedRecording.url and selectedRecording.name to verify that the correct values are being passed to the downloadRecording function.
  2. The file does not download, and the error message appears, which suggests there may be an issue with how the blob URL is being handled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant