You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
What steps will reproduce the problem?
1. run the code I have provided below
What is the expected output? What do you see instead?
I expect a standard return from the ImageshackAPI instead I recieve that the
connection have been refused. I presume this is due to me not knowing what type
the file should be in when I upload.
Code:
public String ImageShack (String imageDir, String myKey) {
//set file
BufferedImage image = null;
File file = new File(imageDir);
//Set namevalue pairs
List<NameValuePair> params = new ArrayList<NameValuePair>();
try
{
image = ImageIO.read(file);
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
ImageIO.write(image, "png", byteArray);
byteArray.flush();
//byte[] byteImage = byteArray.toByteArray();
Base64 base = new Base64(false);
String dataImage = base.encodeAsString(byteArray.toByteArray());
byteArray.close();
dataImage = java.net.URLEncoder.encode(dataImage, "ISO-8859-1");
//Assign name valued pars
params.add(new BasicNameValuePair("key", myKey));
params.add(new BasicNameValuePair("fileupload", dataImage));
params.add(new BasicNameValuePair("format", "json"));
//Create HTTPClient and Client
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://www.imageshack.us/upload_api.php");
//set entities
httpPost.setEntity(new UrlEncodedFormEntity(params));
//Execute & get response
HttpResponse response = httpClient.execute(httpPost);
return response.toString();
}
catch(Exception e)
{
return "Error: " + e.getMessage();
}
}
Original issue reported on code.google.com by [email protected] on 18 Jan 2013 at 12:50
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
[email protected]
on 18 Jan 2013 at 12:50The text was updated successfully, but these errors were encountered: