0

the current code is working but the converted base64string output is attached to the api , but am having 404 error because the request url is too long. so i just need modification , to shorten the converted base64string. or any different approach.

var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { PhotoSize = PhotoSize.Small });

byte[] imageArray = null;

if (file != null)
{

    using (HttpClient client = new HttpClient())

    using (MemoryStream ms = new MemoryStream())
    {
        var stream = file.GetStream();
        stream.CopyTo(ms);
        imageArray = ms.ToArray();
        var base64String = Convert.ToBase64String(imageArray);
phuzi
  • 12,078
  • 3
  • 26
  • 50
  • 2
    you can't make the encoded string shorter without corrupting it. You can resize the image before encoding it. But you really need to look at the API requirements - passing an Base64 encoded image via the url is unusual and really not a good design – Jason Aug 11 '21 at 15:01
  • it would also help if you posted the code for your http request – Jason Aug 11 '21 at 15:02
  • How can i resize the image – adewale adewole Aug 11 '21 at 15:31
  • there are numerous existing questions about resizing images – Jason Aug 11 '21 at 15:31
  • please [edit] your question, do not stuff relevant code in a comment. And I don't see anything that looks like an image in that querystring – Jason Aug 11 '21 at 15:37

0 Answers0