问题描述
前期信息:
Language: Flutter/Dart
Flutter Packages: Flutter_inappwebview,Flutter_downloader
我使用 Flutter 为 Android 构建的移动应用程序出现问题。该应用程序的一项功能是能够下载与 PDF 文件关联的链接。这些文件位于应用程序已经访问的服务器上。用户已通过应用程序登录,因此已建立身份验证。当单击包含 PDF 的 URL 时,它会执行重定向,并返回并下载主页(index.PHP)。我不知道这是怎么发生的,但我有想法。
任何想法或帮助将不胜感激。也很乐意提供更多信息。
在 main.dart 中:
onDownloadStart: (controller,url) async {
print("onDownloadStart $url");
final taskId = await FlutterDownloader.enqueue(
headers: {'My-Custom-Header': 'custom_value=564hgf34'},url: url,savedDir: (await getExternalStorageDirectory()).path,showNotification: true,// show download progress in status bar (for Android)
openFileFromNotification: true,// click on notification to open downloaded file (for Android)
);
return taskId;
},
日志:
I/Flutter (28552): onDownloadStart https://hjhvtc.online/pluginfile.PHP/6723/mod_resource/content/1/Automotive%20industry%20jobs.pdf
W/WM-WorkSpec(28552): Backoff delay duration less than minimum value
D/DownloadWorker(28552): DownloadWorker{url=https://hjhvtc.online/pluginfile.PHP/6723/mod_resource/content/1/Automotive%20industry%20jobs.pdf,filename=null,savedDir=/storage/emulated/0/Android/data/com.coffeepaulconsulting.hjhvtconline/files,header={"My-Custom-Header": "custom_value=564hgf34"},isResume=false
D/DownloadWorker(28552): Update notification: {notificationId: 1,title: https://hjhvtc.online/pluginfile.PHP/6723/mod_resource/content/1/Automotive%20industry%20jobs.pdf,status: 2,progress: 0}
D/DownloadWorker(28552): Open connection to https://hjhvtc.online/pluginfile.PHP/6723/mod_resource/content/1/Automotive%20industry%20jobs.pdf
D/DownloadWorker(28552): Headers = {"My-Custom-Header": "custom_value=564hgf34"}
D/DownloadWorker(28552): Response with redirection code
D/DownloadWorker(28552): Location = https://hjhvtc.online/login/index.PHP
D/DownloadWorker(28552): New url: https://hjhvtc.online/login/index.PHP
D/DownloadWorker(28552): Open connection to https://hjhvtc.online/login/index.PHP
D/DownloadWorker(28552): Headers = {"My-Custom-Header": "custom_value=564hgf34"}
V/InputMethodManager(28552): b/117267690: Failed to get fallback IMM with expected displayId=197 actual IMM#displayId=0 view=com.pichillilorenzo.Flutter_inappwebview.InAppWebView.InAppWebView{4592e22 VFEDHVCL. ......ID 0,0-1080,1997}
D/DownloadWorker(28552): Content-Type = text/html; charset=utf-8
D/DownloadWorker(28552): Content-Length = -1
D/DownloadWorker(28552): Charset = UTF-8
D/DownloadWorker(28552): Content-disposition = null
D/DownloadWorker(28552): fileName = index.PHP
D/DownloadWorker(28552): Update too frequently!!!!,this should be dropped
D/DownloadWorker(28552): There's no application that can open the file /storage/emulated/0/Android/data/com.coffeepaulconsulting.hjhvtconline/files/index.PHP
D/DownloadWorker(28552): Update too frequently!!!!,but it is the final update,we should sleep a second to ensure the update call can be processed
D/DownloadWorker(28552): Update notification: {notificationId: 1,title: index.PHP,status: 3,progress: 100}
D/DownloadWorker(28552): File downloaded
I/WM-WorkerWrapper(28552): Worker result SUCCESS for Work [ id=633dd93d-99e3-46e2-937d-a4782d62a569,tags={ Flutter_download_task,vn.hunghd.Flutterdownloader.DownloadWorker } ]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)