如何在android / base64映像中解决HTTP 414“Request URI too long”错误? [英] How to solve the HTTP 414 “Request URI too long” error in android / base64 image?

查看:2424
本文介绍了如何在android / base64映像中解决HTTP 414“Request URI too long”错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将base64编码的图像从我的应用程序拉到数据库(在我的服务器中),但是我收到了这个错误。

I am trying to pull an base64 encoded image from my app to database(which is in my server), but I get this error.

the server responded with a status of 414 (Request-URI Too Long)

I知道对于URL,缩短它们可以修复错误,但我无法缩短base64字符串。

I know that for URLs, shortening them fixes the error but I can't shorten a base64 string.

如何解决这个问题。

HttpGet httpGet = new HttpGet(URL);

try {

 HttpResponse response = httpClient.execute(httpGet);
        StatusLine statusLine = response.getStatusLine();
        int statusCode = statusLine.getStatusCode();
        if (statusCode == 200) {
            HttpEntity entity = response.getEntity();
            InputStream inputStream = entity.getContent();
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(inputStream));
            String line;
            while ((line = reader.readLine()) != null) {
                stringBuilder.append(line);
            }
            inputStream.close();
        } else {
            Log.d("JSON", "Failed to download file");
        }
    }


推荐答案

尝试改造。在改造中使用@FormUrlEncoded并在@POST(ur_api_name)
中使用@Field(data)注释发送数据。

Try Retrofit. Use @FormUrlEncoded in retrofit and @POST("ur_api_name") and send the data using @Field("data") annotation.

这篇关于如何在android / base64映像中解决HTTP 414“Request URI too long”错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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