duckduckgo / Android

DuckDuckGo Android App
https://play.google.com/store/apps/details?id=com.duckduckgo.mobile.android
Apache License 2.0
3.63k stars 871 forks source link

Issue with Downloaded PDF Filename in Android DuckDuckGo Browser #4612

Closed jeeva-sil closed 3 weeks ago

jeeva-sil commented 3 weeks ago

Describe the bug

I'm trying to download a PDF file with a specific name using HTML and JavaScript. The file is correctly named "myFile.pdf" in the code, but when I download it using the DuckDuckGo browser on an Android device, the file is saved with a random string as its name, such as "f7160bf-07aa-4c50-8765-f3651a345g675.pdf". How can I ensure the file is downloaded with the specified name?

How to Reproduce

Code: Here's the code I'm using to convert a base64 string to a PDF file and download it:

`

<script>
    document.getElementById('downloadBtn').addEventListener('click', function() {
        const base64Data = 'your-base64-string-here'; // replace with your base64 string
        const byteCharacters = atob(base64Data);
        const byteNumbers = new Array(byteCharacters.length);
        for (let i = 0; i < byteCharacters.length; i++) {
            byteNumbers[i] = byteCharacters.charCodeAt(i);
        }
        const byteArray = new Uint8Array(byteNumbers);
        const blob = new Blob([byteArray], { type: 'application/pdf' });
        const link = document.createElement('a');
        link.href = window.URL.createObjectURL(blob);
        link.download = 'myFile.pdf';
        link.click();
    });
</script>

`

Steps to Reproduce: Open the above code in a browser. Click the "Download PDF" button. Observe the downloaded file name. Expected Behavior: The file should download with the name "myFile.pdf".

this is hosted site please check this : https://tempad-51491.web.app/

Actual Behavior: The file downloads with a random string as its name (e.g., "f7160bf-07aa-4c50-8765-f3651a345g675.pdf").

Additional Information: This issue occurs specifically on the DuckDuckGo browser on Android. The code works fine in other browsers (e.g., Chrome, Firefox).

Questions: Why is the DuckDuckGo browser on Android renaming the file? How can I ensure the file downloads with the correct name in the DuckDuckGo browser? Any help or guidance would be greatly appreciated!

Expected behavior

The file should download with the name "myFile.pdf".

Environment

- DDG App Version: 5.202.0
- Device: Nokia 6.1 Plus
- OS: Android 10
github-actions[bot] commented 3 weeks ago

Thank you for opening an Issue in our Repository. The issue has been forwarded to the team and we'll follow up as soon as we have time to investigate. As stated in our Contribution Guidelines, requests for feedback should be addressed via the Feedback section in the Android app.

lmac012 commented 3 weeks ago

Thank you for submitting this report and providing detailed steps to reproduce the issue. We are aware of this problem; however, we are currently limited by the existing WebView API, which doesn’t surface the filename to us in the case of blob URLs, such as the one your code generates.