简体   繁体   中英

Getting error in file download ionic 3 on android 10 sdk29

I am getting following error on android 10 not on lower versions if I am using: downloadDir = cordova.file.externalRootDirectory + 'download/';

const fileTransfer: FileTransferObject = this.transfer.create();
fileTransfer.download(sourceUrl, downloadDir + fileName, false).then((entry) => {
 })

E/FileTransfer( 5726): {"code":1,"source":"https://example.azurewebsites.net/api/interactivelabel/export?ItemCode=1","target":"file:///storage/emulated/0/download/export-1.csv","http_status":200,"exception":"/storage/emulated/0/download/export-1.csv: open failed: EACCES (Permission denied)"} 09-04 06:05:15.497 E/FileTransfer( 5726): java.io.FileNotFoundException: /storage/emulated/0/download/export-1.csv: open failed: EACCES (Permission denied) 09-04 06:05:15.497 E/FileTransfer( 5726): at libcore.io.IoBridge.open(IoBridge.java:496) 09-04 06:05:15.497 E/FileTransfer( 5726): at java.io.FileOutputStream.(FileOutputStream.java:235) 09-04 06:05:15.497 E/FileTransfer( 5726): at org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:329) 09-04 06:05:15.497 E/FileTransfer( 5726): at org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:310) 09-04 06:05:15.497 E/FileTransfer( 5726): at org.apache.cordova.filetransfer.FileTransfer$2.run(FileTransf er.java:811) 09-04 06:05:15.497 E/FileTransfer( 5726): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 09-04 06:05:15.497 E/FileTransfer( 5726): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 09-04 06:05:15.497 E/FileTransfer( 5726): at java.lang.Thread.run(Thread.java:919) 09-04 06:05:15.497 E/FileTransfer( 5726): Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied) 09-04 06:05:15.497 E/FileTransfer( 5726): at libcore.io.Linux.open(Native Method) 09-04 06:05:15.497 E/FileTransfer( 5726): at libcore.io.ForwardingOs.open(ForwardingOs.java:167) 09-04 06:05:15.497 E/FileTransfer( 5726): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252) 09-04 06:05:15.497 E/FileTransfer( 5726): at libcore.io.ForwardingOs.open(ForwardingOs.java:167) 09-04 06:05:15.497 E/FileTransfer( 5726): at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7893) 09-04 06:05:15.497 E/FileTransfer( 5726): at libcore.io.IoBridge.open(IoBridge.java:482) 09-04 06:05:15.497 E/FileTransfer( 5726): ... 7 more

android:requestLegacyExternalStorage="true"

将其添加到清单文件中的应用程序标记。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM