dl: filename

pull/653/merge
Varun Patil 2023-05-08 20:30:23 -07:00
parent 6f11b5eeba
commit e8baff4273
1 changed files with 4 additions and 1 deletions

View File

@ -88,7 +88,7 @@ public class NativeX {
}
@JavascriptInterface
public void downloadFromUrl(final String url) {
public void downloadFromUrl(final String url, final String filename) {
Uri uri = Uri.parse(url);
DownloadManager manager = (DownloadManager) mActivity.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
@ -98,6 +98,9 @@ public class NativeX {
String cookies = android.webkit.CookieManager.getInstance().getCookie(url);
request.addRequestHeader("cookie", cookies);
// Save the file to external storage
request.setDestinationInExternalPublicDir(android.os.Environment.DIRECTORY_DOWNLOADS, "memories/" + filename);
// Start the download
manager.enqueue(request);
}