[英]Reason for not being able to search the app-specific files in Android and solution
I am building a react native app which includes pdf file download and image upload functionality.我正在构建一个反应原生应用程序,其中包括pdf 文件下载和图像上传功能。
For doing file download, I am using react-native-fs and react-native-html-to-pdf and for image upload, I am using the axios and react-native-image-crop-picker .对于文件下载,我使用react-native-fs和react-native-html-to-pdf并且对于图像上传,我使用axios和react-native-image-crop- picker 。
I have already implemented the image upload functionality long time ago and it worked like charm.我很久以前就已经实现了图像上传功能,它就像魅力一样。
In these days, I have implemented the pdf file download functionality and also it works well.这些天来,我已经实现了pdf 文件下载功能,并且运行良好。
PROBLEM问题
Error message which is logged by react-native log-android
looks like this: Network error
_response: 'Could not retrieve file for uri /storage/emulated/0/Android/data/packageName/files/Pictures/75a08b1a-98de-4811-8b44-453f6f2f9bf8.jpg',
react-native log-android
记录的错误消息如下所示: Network error
_response: 'Could not retrieve file for uri /storage/emulated/0/Android/data/packageName/files/Pictures/75a08b1a-98de-4811-8b44-453f6f2f9bf8.jpg',
Download pdf file path is like this: /storage/emulated/0/Android/data/packageName/files/data/user/0/packageName/files/fileName.pdf
and I have checked this is definitely exist in exact directory.下载 pdf 文件路径是这样的:
/storage/emulated/0/Android/data/packageName/files/data/user/0/packageName/files/fileName.pdf
我已经检查过这肯定存在于确切的目录中。
What I am wondering is我想知道的是
What I did for test image upload我为测试图片上传做了什么
What I assumed is我假设的是
Actual codes实际代码
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="packageName">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme" android:usesCleartextTraffic="true" android:requestLegacyExternalStorage="true">
<activity android:exported="true" android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="invitation"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="deeplinkUrl"
android:scheme="https"/>
</intent-filter>
</activity>
<!-- Facebook login -->
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
<!-- Facebook login -->
</application>
<queries>
<intent>
<action android:name="android.intent.action.VIEW"/>
<data android:mimeType="*/*"/>
</intent>
</queries>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="appdownloads" path="Download/" />
<external-path name="files" path="/" />
<root-path name="root" path="." />
</paths>
I think this is related to Android and local pc device.我认为这与 Android 和本地 pc 设备有关。 it would be nice if you can let us know about your development environment
如果您能告诉我们您的开发环境,那就太好了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.