Forum Xamarin.Forms

Upload image Laravel POST Error on response body

MaaaxMaaax Member
edited March 2020 in Xamarin.Forms

Hello guys,
If I upload over Insomnia an image to my Laravel application everything is ok and I get following log :

[2020-03-04 05:26:39] local.DEBUG: array (
  'image' => 
  Illuminate\Http\UploadedFile::__set_state(array(
     'test' => false,
     'originalName' => 'Screenshot_1583210368.png',
     'mimeType' => 'image/png',
     'error' => 0,
     'hashName' => NULL,
  )),
)

But if I upload an image on android emulator the log file in Laravel looks like (1000+ lines) :

�"@�G����ޠ��U��H��I�G"Ĉ.SB^G`

This is my Xamarin Function :
public async Task<string> uploadImage(Stream stream)
        {
            using (var client = new HttpClient())
            {


                var content = new MultipartFormDataContent();


                content.Add(new StreamContent(stream),"image");


                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", (Application.Current.Properties["access_token"].ToString()));


                var result = await client.PostAsync("https://example.com/api/upload/image", content);

                return "";
            }
        } 
Sign In or Register to comment.