I am building a react native app which includes pdf file download and image upload functionality.
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 .
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.
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',
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.
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. it would be nice if you can let us know about your development environment
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.