Get progress of my upload with nuget

LucculLuccul FRMember ✭✭


I use this nuget to upload my image to imgur with Xamarin.Forms.

I want to get my upload progression.

This is my code :

public async Task UploadImage(Stream source)
    var client = new ImgurClient(ConstantKeys.ImgurClientId, ConstantKeys.ImgurClientSecret);
    var endpoint = new ImageEndpoint(client);

        var image = await endpoint.UploadImageStreamAsync(source);  

        var link = image.Link;
        ImageLink = link;
    catch (Exception ex)
        Debug.WriteLine(@"/!\ DEBUG - UploadImage method : " + ex.Message);

The owner link me this tutorial, but i never worked with Progress, and i need help:

Any suggestion ?

Thank you

Best Answer


  • JulienRosenJulienRosen CAMember ✭✭✭✭

    you would need endpoint.UploadImageStreamAsync to be able to report its progress back to you so you can display it. doesn't look like this is the case.

  • LucculLuccul FRMember ✭✭
    edited May 2016

    Yes and i don't find how i can do that.

    I try to create my own uploader, but i have this issue: Uri is longer than the maximum 32766 characters

    private string ImageToBase64(Stream stream)
                var memoryStream = new MemoryStream();
                var result = memoryStream.ToArray(); 
                var base64img = Convert.ToBase64String(result);
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < base64img.Length; i += 32766)
                    sb.Append(Uri.EscapeDataString(base64img.Substring(i, Math.Min(32766, base64img.Length - i))));
                return sb.ToString();
  • JulienRosenJulienRosen CAMember ✭✭✭✭

    i doubt the imgur api expects images in base64 on the url

Sign In or Register to comment.