I have uploaded image using a http://... URL. but i dont want to use URL .I want to upload image on tumbler from local sdcard of mobile. I tried all these solutions Uploading Images to tumblr API from Android but nothing worked for me.
i posted image by URL like this :-
File fil = savebitmap(pattern_a);
HttpPost hpost = new HttpPost("http://api.tumblr.com/v2/blog/"
+ strBlogName.replace(" ", "%20") + ".tumblr.com/post");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("type", "photo"));
nameValuePairs.add(new BasicNameValuePair("caption", "hello"));
nameValuePairs.add(new BasicNameValuePair("source","http://pchtanks.com/wp-content/uploads/2013/10/tropical-fish11.jpg"));
UPDATE
I am using this code
nameValuePairs.add(new BasicNameValuePair("type", "photos"));
nameValuePairs.add(new BasicNameValuePair("set_total", "1"));
nameValuePairs.add(new BasicNameValuePair("name", "Akanksha"));
nameValuePairs.add(new BasicNameValuePair("caption", "Hello yar"));
nameValuePairs.add(new BasicNameValuePair("original","0"));
nameValuePairs.add(new BasicNameValuePair("data", fil.getAbsolutePath().toString()));
nameValuePairs.add(new BasicNameValuePair("source", encodedImage));
// localContentValues2.put("tumblr_post_id", Long.valueOf(paramLong));
nameValuePairs.add(new BasicNameValuePair("width", String.valueOf(pattern_a.getWidth())));
nameValuePairs.add(new BasicNameValuePair("height", String.valueOf(pattern_a.getHeight())));
localArrayList.add(nameValuePairs);
hpost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
consumerconsumer.sign(hpost);
DefaultHttpClient client = new DefaultHttpClient();
org.apache.http.HttpResponse resp = null;
resp = client.execute(hpost);
result = EntityUtils.toString(resp.getEntity());
PrintLog.LOGV("Result : " + result);
I got the encodedImage like this :-
ByteArrayOutputStream stream = new ByteArrayOutputStream();
pattern_a.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] byteArray = stream.toByteArray();
String encodedImage = Base64.encodeToString(byteArray, Base64.DEFAULT);
I am getting Error : - Bed request, Post can not be empty.
I think i am missing something in parameter or i am sending any wrong tag.
Do any body have any solution.
I have downloaded jumblr jar file. but i don't know how to use it. Is my work is possible without jumbler. Please reply.