Hi I'm trying to figure out how to upload to imgur using java, does anyone have any experience with this kind of thing?
Asked
Active
Viewed 6,114 times
4 Answers
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.

Phil Ross
- 25,590
- 9
- 67
- 77
5
Get a developer key.
Look at their Image Upload API.
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.

hd1
- 33,938
- 5
- 80
- 91

Pascal Thivent
- 562,542
- 136
- 1,062
- 1,124
-
1If HttpClient is too overwhelmed, you could also just use `java.net.URLConnection` with `setDoOutput(true)` and write `image=...&key=...` to its `OutputStream`. – BalusC Nov 28 '09 at 22:40
-
@BalusC 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. – moomoohk May 26 '13 at 05:24
-
@MeshulamSilk: http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests/2793153#2793153 – BalusC May 26 '13 at 11:37
-
@BalusC Thanks! I'll be sure to have a look at that. – moomoohk May 28 '13 at 07:36
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.

Geo
- 93,257
- 117
- 344
- 520