Whenever I try to send form data or files to the server from my native code I am not getting the assets[0].fileSize and assets[0].fileName in native console.
My React Native Code is:
const { status } = await Permissions.askAsync(Permissions.MEDIA_LIBRARY); if (status !== "granted") { // Handle permission denied return; } const result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.Images });
console.log(result);
I am getting this output from result:
{ assets: [ { assetId: "1610", base64: null, duration: null, exif: null, height: 1840, rotation: null, type: "image", uri: "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252Fhelo-c554b96a-1355-4a71-8550-01d96488539b/ImagePicker/21bc87ec-4534-40d8-a86d-bd676ad9cbb2.jpeg", width: 3264, }, ], canceled: false, cancelled: false, };
Here is the documentation result:
{ "assets": [ { "assetId": "C166F9F5-B5FE-4501-9531", "base64": null, "duration": null, "exif": null, "fileName": "IMG.HEIC", "fileSize": 6018901, "height": 3025, "type": "image", "uri": "file:///data/user/0/host.exp.exponent/cache/cropped1814158652.jpg" "width": 3024 } ], "canceled": false, "cancelled": false }
I am using expo-image-picker for selecting images.
And in server side I am using multer().any() for handling files coming to server.
I have have tried some more packages: xhr for file upload but didn’t work.
Kuldeep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.