Im trying to upload a Image in backend using Appwrite. It requires attributes such as fileName,type,uri,fileSize. But when I capture the Image using camera using ImagePicker.launchCameraAsync()
it contains attributes such as uri,type,size,etc. but the fileName and assetId is null
. It works fine when I select Image from my gallery using ImagePicker.launchImageLibraryAsync()
as it contains data for all attributes. Here is my code
const takePhoto = async () => {
const { status } = await ImagePicker.requestCameraPermissionsAsync();
if (status !== 'granted') {
Alert.alert('Sorry, we need camera permissions to make this work!');
return;
}
const result = await ImagePicker.launchCameraAsync({
allowsEditing: true,
aspect: [4, 3],
quality: 1,
});
console.log(result,"photo taken in camera");
this is the console.log() output :
{"assets": [{"assetId": null, "base64": null, "duration": null, "exif": null, "fileName": null, "fileSize": 7301631, "height": 3025, "mimeType": "image/jpeg", "type": "image", "uri": "file:///var/mobile/Containers/Data/Application/BB32C249-451A-4087-A1A4-6D58724A0FA6/Library/Caches/ExponentExperienceData/@anonymous/shoplook-03082981-c4c4-42c7-96be-7cf4d4f49be6/ImagePicker/901109CD-75B2-4E58-9BBC-8E8921D9070A.jpg", "width": 3024}], "canceled": false} photo taken in camera
I tried to manually set the variable if photo is captured but this solution is not optimal and is only a temporary fix. So I need to know whether it is a problem for only Iphones or it is a general problem and is there any fix available.