[英]Reason for not being able to search the app-specific files in Android and solution
我正在構建一個反應原生應用程序,其中包括pdf 文件下載和圖像上傳功能。
對於文件下載,我使用react-native-fs和react-native-html-to-pdf並且對於圖像上傳,我使用axios和react-native-image-crop- picker 。
我很久以前就已經實現了圖像上傳功能,它就像魅力一樣。
這些天來,我已經實現了pdf 文件下載功能,並且運行良好。
問題
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',
下載 pdf 文件路徑是這樣的: /storage/emulated/0/Android/data/packageName/files/data/user/0/packageName/files/fileName.pdf
我已經檢查過這肯定存在於確切的目錄中。
我想知道的是
我為測試圖片上傳做了什么
我假設的是
實際代碼
<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>
我認為這與 Android 和本地 pc 設備有關。 如果您能告訴我們您的開發環境,那就太好了
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.