I use 'expo-image-picker' library to get image.
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
aspect: [3, 3],
quality: 0,
allowsMultipleSelection: false,
allowsEditing: true,
});
I try to set quality = 0 but when I send request by method post to server, I get** 413 error.**
const register = async (data, image) => {
const bodyFormData = new FormData();
bodyFormData.append('name', data.name);
console.log(image);
if (image) {
const fileType = image.split('.').pop();
const mimeType =
fileType === 'png' || 'jpg' || 'jpeg' || 'PNG' || 'JPG' || 'JPEG';
bodyFormData.append('avatar', {
uri: image,
name: `image.${fileType}`,
type: mimeType,
});
}
bodyFormData.append('email', data.email);
bodyFormData.append('password', data.password);
return await requester({
requestFunc: () =>
Request.Server.post(API_SERVER.REGISTER(), bodyFormData, {
headers: {
'Content-Type': 'multipart/form-data',
},
}),
})();
};
I tried to send a request with some low resolution photos, but it still works.
I also find out about "Expo ImageManipulator" library, but it also set "quality" same as "expo-image-picker" library.
If the image is extremely large then setting the quality like that is really not optimal, so is there any way to limit it?
Sorry because my Englist is not good, thank everyone!