上传从SD卡图像不倒翁Android中 [英] Upload image from sd-card on tumbler in Android

查看:122
本文介绍了上传从SD卡图像不倒翁Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经上传影像使用的http:// ... URL。但我不希望使用URL。我想从手机本地SD卡上传图片的不倒翁。 我想所有这些解决方案<一href="http://stackoverflow.com/questions/13845208/uploading-images-to-tumblr-api-from-android">Uploading从Android的但没有图像至tumblr API为我工作。

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"));

更新

我用这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);

我得到了EN codeDIMAGE是这样的: -

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 think i am missing something in parameter or i am sending any wrong tag.

做任何机构有任何解决方案。照片 我已经下载jumblr jar文件。但我不知道如何使用它。是我的工作可能不jumbler。请回复。

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.

推荐答案

源不期望的URL。该公司预计URI。你尝试: nameValuePairs.add(新BasicNameValuePair(源,文件:///sdcard/img.png));

The source does not expect URL. It expects URI. Did you try :nameValuePairs.add(new BasicNameValuePair("source","file:///sdcard/img.png")); ?

此外,而不是源代码,您可以指定数据和使用的ByteBuffer提供图像的实际字节

Moreover, instead of source, you can specify data and supply the actual bytes of the image using a bytebuffer

这篇关于上传从SD卡图像不倒翁Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆