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

  • SEARCH
  • Home
  • 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 6346925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:06:42+00:00 2026-05-24T21:06:42+00:00

I need help in using, imgur’s API, to upload a photo and obviously retrieve

  • 0

I need help in using, imgur’s API, to upload a photo and obviously retrieve a link.

IMGUR API:
http://api.imgur.com/resources_anon

I’m able to get the URI for my image required to be uploaded but how can I implement the api above,
I’ve downloaded mime4j and httpmime and added them to the libraries, but I can’t seem to understand how to use them,

I looked at this but its confused me :
Sending images using Http Post

  • 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-05-24T21:06:43+00:00Added an answer on May 24, 2026 at 9:06 pm

    Just from having a quick look at imgur and this question, I’ve come up with (pretty much just combined the two) the following. Let me know if it doesn’t work.

    Bitmap bitmap = yourBitmapHere;
    
    // Creates Byte Array from picture
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); // Not sure whether this should be jpeg or png, try both and see which works best
    URL url = new URL("http://api.imgur.com/2/upload");
    
    //encodes picture with Base64 and inserts api key
    String data = URLEncoder.encode("image", "UTF-8") + "=" + URLEncoder.encode(Base64.encode(baos.toByteArray(), Base64.DEFAULT).toString(), "UTF-8");
    data += "&" + URLEncoder.encode("key", "UTF-8") + "=" + URLEncoder.encode(YOUR_API_KEY, "UTF-8");
    
    // opens connection and sends data
    URLConnection conn = url.openConnection();
    conn.setDoOutput(true);
    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write(data);
    wr.flush();
    

    Edit: It seems we need to pass Base64.DEFAULT as the second option to Base64.encode. Updated the example above.

    Edit 2: Can you use the following code, based upon the oracle site, and report back what it outputs:

    BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                conn.getInputStream()));
    
    String inputLine;
    
    while ((inputLine = ic.readLine()) != null) 
        System.out.println(inputLine);
    in.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help with this question. I'm using the camel-http component as shown here
I need some help with aligning the text. I want to achieve this https://i.stack.imgur.com/3aKvl.jpg
I need big help from you,I want to upload image using amazon s3 web
I need some help in using Google AJAX Feed API. As we know by
Need help writing a script downloads data from google insight using c# this is
We are using Linq-to-SQL with stored Procedures we need help on one of our
I need some help with overlaying views using the prism framework.Its a little more
I need some help extracting the following bits of information using regular expressions. Here
I need some help on compiler flags in c++. I'm using a library that
I need to create HTML pop-up menu using Perl. Can anyone help me?

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.