mirror of
https://github.com/status-im/react-native-webview.git
synced 2026-08-31 03:31:05 +00:00
fix(android): Fix Download on android P (#273)
Fixes #266. Now downloading works on Motorola Moto One with Android 9.
This commit is contained in:
committed by
Thibault Malbranche
parent
c518f716c6
commit
15d904f769
@@ -7,7 +7,6 @@ import com.facebook.react.uimanager.UIManagerModule;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -480,16 +479,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
|
||||
|
||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
|
||||
|
||||
//Try to extract filename from contentDisposition, otherwise guess using URLUtil
|
||||
String fileName = "";
|
||||
try {
|
||||
fileName = contentDisposition.replaceFirst("(?i)^.*filename=\"?([^\"]+)\"?.*$", "$1");
|
||||
fileName = URLDecoder.decode(fileName, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error extracting filename from contentDisposition: " + e);
|
||||
System.out.println("Falling back to URLUtil.guessFileName");
|
||||
fileName = URLUtil.guessFileName(url,contentDisposition,mimetype);
|
||||
}
|
||||
String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
|
||||
String downloadMessage = "Downloading " + fileName;
|
||||
|
||||
//Attempt to add cookie, if it exists
|
||||
|
||||
Reference in New Issue
Block a user