Upload to imgur java
Asked Answered
B

4

5

Hi I'm trying to figure out how to upload to imgur using java, does anyone have any experience with this kind of thing?

Bangle answered 28/11, 2009 at 21:35 Comment(0)
D
6

First of all, you're likely to be best off using the imgur api.

The documentation for uploading contains examples for Python and PHP that use cURL. It should be possible to adapt these to the Java bindings for cURL, or other HTTP libraries such as HttpClient.

Doiron answered 28/11, 2009 at 22:5 Comment(0)
A
5
  1. Get a developer key.

  2. Look at their Image Upload API.

  3. Use Apache Commons HttpClient to create a POST request and send:

    • 'image' - A binary image file, base64 encoded string, or URL.
    • 'key' - Your registered developer API key. Click here to register for a key.
Acidosis answered 28/11, 2009 at 22:30 Comment(4)
If HttpClient is too overwhelmed, you could also just use java.net.URLConnection with setDoOutput(true) and write image=...&key=... to its OutputStream.Zarathustra
@Zarathustra I know your reply is super old but I'm just coming across it now and was wondering if you were willing to provide some code implementing this. I have my Imgur key as well as my binary image, I just can't for the life of me wrap my head around URLConnection.Romalda
@MeshulamSilk: #2793650Zarathustra
@Zarathustra Thanks! I'll be sure to have a look at that.Romalda
B
0

You could try cURL. http://curl.haxx.se/libcurl/java/

Bratwurst answered 28/11, 2009 at 21:53 Comment(0)
R
0

I've used HtmlUnit with great success for this sort of tasks. Read the Submitting a form in the Getting started section, and you'll be done in no time.

Reparation answered 28/11, 2009 at 21:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.