Мое приложение принудительно закрывается при выборе изображения из галереи
I got problem when I choose picture with size 500 Kb from my gallery and my application force close. But if i choose picture with size 100-250kb it is success load image and send base64 to my database. Could you help me how to fix it ? It is message error when i choose picture with 500kb: Refit.ApiException: 'Response status code does not indicate success: 500 (Internal Server Error).'
Что я уже пробовал:
This is my coding from mobile app:
async void SavePicture(object sender, EventArgs e) { file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { PhotoSize = PhotoSize.Small //CompressionQuality = 100, }); if (file == null) return; //Convert image to string FileStream fs = new FileStream(file.Path, FileMode.Open, FileAccess.Read); byte[] ImageData = new byte[fs.Length]; fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); string imgResized = Convert.ToBase64String(ImageData); imageResize.Source = file.Path; api = RestService.For<ApiInterface> ("http://192.168.0.190/webservice/webservice.asmx"); String idgoogle = ""; var id = Application.Current.Properties["Id"].ToString(); var stringimage = imgResized; User user = new User(idgoogle); user.Profile_Image = stringimage; user.Id = id; var responseupdate = await api.UpdateGoogle(new UpdateGoogleQuery(user)); if (responseupdate.isSuccess) { Loading.toast("Sukses Menyimpan Foto"); } else { LoadingFailed.toast("Gagal Menyimpan Foto"); } }
This is my coding from webservice
public void update(User dtGoogle) { String sql = $"UPDATE google SET profile_image = ('{dtGoogle.Profile_Image}') WHERE id = ('{dtGoogle.Id}')"; Connection.executeSql(sql); }