Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8900525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:07:06+00:00 2026-06-15T01:07:06+00:00

public sealed class ImgurUpload { public event EventHandler<UploadCompleteEventArgs> UploadComplete; public void PostToImgur(string location, string

  • 0
public sealed class ImgurUpload
{
    public event EventHandler<UploadCompleteEventArgs> UploadComplete;

    public void PostToImgur(string location, string key, string name = "", string caption = "")
    {
        try
        {
            using (var webClient = new WebClient())
            {
                NameValueCollection values = new NameValueCollection
                {
                    { "image", ConvertToBase64(location) },
                    { "key", key },
                    { "name", name },
                    { "caption", caption}
                };
                webClient.UploadValuesAsync(new Uri("http://api.imgur.com/2/upload.xml"), "POST", values);
                webClient.UploadValuesCompleted += ((sender, eventArgs) =>
                {
                    byte[] response = eventArgs.Result;
                    XDocument result = XDocument.Load(XmlReader.Create(new MemoryStream(response)));
                    if (UploadComplete != null)
                        UploadComplete(this, new UploadCompleteEventArgs(result));
                });
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);  
        }
    }

    private string ConvertToBase64(string imageLocation)
    {
        byte[] imageData = null;
        using (FileStream fileStream = File.OpenRead(imageLocation))
        {
            imageData = new byte[fileStream.Length];
            fileStream.Read(imageData, 0, imageData.Length);
        }
        return Convert.ToBase64String(imageData);
    }
}

public class UploadCompleteEventArgs : EventArgs
{
    public string Original { get; private set; }
    public string ImgurPage { get; private set; }
    public string DeletePage { get; private set; }

    public UploadCompleteEventArgs(XDocument xmlDoc)
    {
        var objLinks = from links in xmlDoc.Descendants("links")
                       select new
                       {
                           original = links.Element("original").Value,
                           imgurPage = links.Element("imgur_page").Value,
                           deletePage = links.Element("delete_page").Value
                       };

        Original = objLinks.FirstOrDefault().original;
        ImgurPage = objLinks.FirstOrDefault().imgurPage;
        DeletePage = objLinks.FirstOrDefault().deletePage;
    }
}

Above is a class I wrote to upload an image to imgur using the Anonymous API. I have used the API in the past and have always found it to be considerably slower than the website uploader and slower than other .NET applications that use web requests to effectively send data to the website directly rather than using the API.

I posted the full class above as it may be something I’m doing (or not doing) that’s causing the issue. I’d really appreciate it if anybody can identify the issue for me.

I did some fair testing earlier today and one result for example, is as followed:

  • 800kb image via the imgur website = 35 seconds
  • 800kb image via using my class = 1minute 20 seconds
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:07:07+00:00Added an answer on June 15, 2026 at 1:07 am

    The one you are uploading is ~35% bigger because you’re uploading it as a STRING.

    Upload via bytes and it should be just as fast.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public sealed class FtpManager { public event EventHandler LoggingIn = delegate { }; private
Given a class: [DataContract] public sealed class ChangedField { [DataMember(Name=I)] public ushort FieldId {
I have the following class [DataContract(Namespace = , Name = VersionRange)] public sealed class
sealed public class HMethod { public int Calc(string Method, int X1, int X2, int
The HtmlDocument class has the following attribute: [PermissionSet(SecurityAction.LinkDemand, Name=FullTrust)] public sealed class HtmlDocument Why?
public sealed class IntegerBox : TextBox { #region constants private const string RangeConstraintValidatorID =
I have [Imported] public sealed class ServerResult : Record { public string Message; public
Model: public sealed class Model { public string Value { get; set; } }
Event System handler code: [TcmExtension(My Handler)] public sealed class EventSystem : TcmExtension { public
Consider this class: [Persistable] public sealed class FileMoveTask : TaskBase { [PersistMember] public string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.