Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF "Download Unsuccessful" Only on Android Phones

Tags:

android

pdf

I know similar questions have been asked, but none of them were answered. As the heading suggests, a PDF document is successfully retrieved on PC as well as iPhones from the URL (URL calls the controller of a C# Web API and the function returns a PDF in HttpWebResponse), but as soon as it comes to Android phones, it says "Download Unsuccessful", unless the link is opened in Opera.

The code below shows how the web response from the third party web service is converted to pdf and displayed:

bytes = Convert.FromBase64String(node.Value);
res.Content = new ByteArrayContent(bytes);
res.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");                                 
res.Content.Headers.Add("Content-Disposition", "inline; filename=NatisDocument.PDF");

I have tried changing the mime type to application/octet-steam, it still does the same thing, and I have been stuck on the same issue for 2 working days.

Can anyone help? Or has experienced the same frustration?

like image 595
Rexxar Avatar asked Sep 02 '15 16:09

Rexxar


People also ask

Why does my download manager keep saying Download unsuccessful?

It may just be an server error just try again or try a different source, if the error still reoccurs then just try a different browser such UC & Opera, i havn't seen a download fail in these two unless it is from a really bad source. What is the download mode on Android? Some apps suddenly quit when opening in Android.

How do I fix untitled downloads?

Go to Settings>Apps, tap Menu>Show System, select Download Manager, then Storage, then Clear Cache/Clear Data.


1 Answers

On an Android 4.4.2 device I have no problem with 'online' opening of PDF in Mozilla Firefox. However, the "Download Unsuccessful" error occurs in Google Chrome and the native Android browser only when retrieving PDF from secure URL (https://...). In such a case, do not tap on link, but press on link and choose 'Save link' in the context menu; then press 'Open'. See also https://android.stackexchange.com/questions/62894/android-download-pdf-giving-download-unsuccessful

like image 179
user3506298 Avatar answered Oct 04 '22 12:10

user3506298