Hi I'm trying to figure out how to upload to imgur using java, does anyone have any experience with this kind of thing?
Upload to imgur java
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.
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.
@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: #2793650 –
Zarathustra
@Zarathustra Thanks! I'll be sure to have a look at that. –
Romalda
You could try cURL. http://curl.haxx.se/libcurl/java/
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.
© 2022 - 2024 — McMap. All rights reserved.
java.net.URLConnection
withsetDoOutput(true)
and writeimage=...&key=...
to itsOutputStream
. – Zarathustra