flutter_downloader icon indicating copy to clipboard operation
flutter_downloader copied to clipboard

D/DownloadWorker( 7340): Content-Type = application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. D/DownloadWorker( 7340): Setting an intent to open the file /storage/emulated/0/Download/order_report_2022-06-17 05_40_14.pdf.xlsx

Open Lazizbek97 opened this issue 3 years ago • 5 comments

I'm downloading pdf file but it returns me .xlsx file as downloaded. Like this: order_report_2022-06-17 05_40_14.pdf.xlsx

D/DownloadWorker( 7340): DownloadWorker{url=https://test.cdn.grocery.billz.work/excel/order_report_2022-06-17 05:40:14.pdf,filename=order_report_2022-06-17 05:40:14.pdf,savedDir=//storage/emulated/0/BillzUz,header=,isResume=false,status=1 D/DownloadWorker( 7340): Update notification: {notificationId: 6, title: order_report_2022-06-17 05:40:14.pdf, status: 2, progress: 0} D/DownloadWorker( 7340): Open connection to https://test.cdn.grocery.billz.work/excel/order_report_2022-06-17 05:40:14.pdf I/ViewRootImpl@30d50c3[MainActivity]( 7340): MSG_WINDOW_FOCUS_CHANGED 0 1 D/DownloadWorker( 7340): Content-Type = application/vnd.openxmlformats-officedocument.spreadsheetml.sheet D/DownloadWorker( 7340): Content-Length = 27867 D/DownloadWorker( 7340): Charset = null D/DownloadWorker( 7340): fileName = order_report_2022-06-17 05:40:14.pdf D/DownloadWorker( 7340): Update notification: {notificationId: 6, title: order_report_2022-06-17 05:40:14.pdf, status: 2, progress: 14} D/DownloadWorker( 7340): Update too frequently!!!!, this should be dropped D/DownloadWorker( 7340): Update too frequently!!!!, this should be dropped D/DownloadWorker( 7340): Update too frequently!!!!, this should be dropped D/DownloadWorker( 7340): Update too frequently!!!!, this should be dropped D/DownloadWorker( 7340): Update too frequently!!!!, this should be dropped D/DownloadWorker( 7340): Update too frequently!!!!, this should be dropped D/DownloadWorker( 7340): Setting an intent to open the file /storage/emulated/0/Download/order_report_2022-06-17 05_40_14.pdf.xlsx D/DownloadWorker( 7340): Update too frequently!!!!, but it is the final update, we should sleep a second to ensure the update call can be processedD/DownloadWorker( 7340): Update notification: {notificationId: 6, title: order_report_2022-06-17 05:40:14.pdf, status: 3, progress: 100} D/DownloadWorker( 7340): File downloaded I/WM-WorkerWrapper( 7340): Worker result SUCCESS for Work [ id=c1f5dfd6-d224-49e2-9b0a-2694f81cdcba, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]

Lazizbek97 avatar Jun 17 '22 06:06 Lazizbek97

I'm downloading pdf file but it returns me .xlsx file as downloaded. Like this: order_report_2022-06-17 05_40_14.pdf.xlsx I cannot find where and how to fix it

Lazizbek97 avatar Jun 17 '22 06:06 Lazizbek97

The url you provide return the mimetype of xlsx instead of the mimetype of pdf in the header field content-type. Either you can make the backend to return the correct content type, or you can set the fileName field in FlutterDownloader.enqueue method explicitly.

ebwood avatar Jun 17 '22 06:06 ebwood

Firstly, thank you for the answers. I've explicitly set the name for FlutterDownloader.enqueue method. But it doesn't work. So only the last solution is to send correct content-type from backend? Friday, 17 June 2022, 11:54AM +05:00 from FaKenKoala @.*** :

The url you provide return the mimetype of xlsx instead of the mimetype of pdf in the header field content-type. Either you can make the backend to return the correct content type, or you can set the fileName field in FlutterDownloader.enqueue method explicitly. — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you authored the thread. Message ID: @ github . com>

Lazizbek97 avatar Jun 17 '22 07:06 Lazizbek97

Oh sorry for my fault response. A solution is to send correct content-type. After digging into the android source code, in the DownloadWorker.java file line 398, when your android device sdk is not less then 29, and you set saveInPublicStorage to true, then it will add the right extension if you provide the wrong extension in the file name. So another solution is to set saveInPublicStorage to false. Hope it helps you.

ebwood avatar Jun 17 '22 08:06 ebwood

Thank you it worked for me. I've changed content-type from backend.

Lazizbek97 avatar Jun 17 '22 10:06 Lazizbek97

Thanks for helping @FaKenKoala. I'm assuming this is solved and closing.

bartekpacia avatar Aug 21 '22 20:08 bartekpacia