如何解决android / base64图像中的HTTP 414“Request URI too long”错误?

Kar*_*hik 3 android http

我正在尝试将 base64 编码的图像从我的应用程序提取到数据库(位于我的服务器中),但出现此错误。

the server responded with a status of 414 (Request-URI Too Long)
Run Code Online (Sandbox Code Playgroud)

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

这个怎么修。

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");
        }
    }
Run Code Online (Sandbox Code Playgroud)

小智 5

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