简体   繁体   English

Http发布请求参数限制

[英]Http post request parameters limit

I'm try to pass 19(images) parameters to htttp post request, but when I put more then 9 params, my app don't do the upload to server, I recheck all the code and is ok, server side is ok also. 我尝试将19(images)参数传递给htttp发布请求,但是当我放置9个以上的参数时,我的应用程序不执行向服务器的上传,我重新检查了所有代码,一切正常,服务器端也正常。

@Override
protected String doInBackground(Void... params) {
    Log.d("SETIMAGE", "IMAGEM DOINBACKGROUND INIT");
    RequestHandler rh = new RequestHandler();
    HashMap<String,String> param = new HashMap<String,String>();

    param.put(KEY_ID,id);
    param.put(KEY_CHAMADO,chamado);

    param.put(FACHADA,imageFachada);
    param.put(RADIO,imageRadio);
    param.put(SUPORTE,imageSuporte);
    param.put(MASTRO,imageMastro);
    param.put(ISOLAMENTO,imageIsolamento);
    param.put(INFRAEXT1,imageInfraExt1);
    param.put(INFRAEXT2,imageInfraExt2);
    param.put(INFRAINT1,imageInfraInt1);
    param.put(INFRAINT2,imageInfraInt2);
    param.put(CONECTOREXT,imageConectorExt);
    param.put(CONECTORINT,imageConectorInt);
    param.put(SALATEC,imageSalaTec);
    param.put(RACK,imageRack);
    param.put(IDU,imageIDU);
    param.put(TOMADAIDU,imageTomadaIDU);
    param.put(AZIMUTE,imageAzimute);
    param.put(GPS,imageGPS);
    param.put(MTCABOEXT,imageMtCaboExt);
    param.put(MTCABOINT,imageMtCaboInt);

    String result = rh.sendPostRequest(UploadUrl, param);
    Log.d("RESULT", result);
    return result;
}

This is via RequestHandler.class 这是通过RequestHandler.class

public String sendPostRequest(String requestURL, HashMap<String, String> postDataParams) {
    //Creating a URL
    URL url;

    //StringBuilder object to store the message retrieved from the server
    StringBuilder sb = new StringBuilder();
    try {
        //Initializing Url
        url = new URL(requestURL);

        //Creating an httmlurl connection
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        //Configuring connection properties
        conn.setReadTimeout(150000);
        conn.setConnectTimeout(150000);
        conn.setRequestMethod("POST");
        conn.setDoInput(true);
        conn.setDoOutput(true);

        //Creating an output stream
        OutputStream os = conn.getOutputStream();

        //Writing parameters to the request
        //We are using a method getPostDataString which is defined below
        BufferedWriter writer = new BufferedWriter(
                new OutputStreamWriter(os, "UTF-8"));
        writer.write(getPostDataString(postDataParams));

        writer.flush();
        writer.close();
        os.close();
        int responseCode = conn.getResponseCode();

        if (responseCode == HttpsURLConnection.HTTP_OK) {
            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            sb = new StringBuilder();
            String response;
            //Reading server response
            while ((response = br.readLine()) != null) {
                sb.append(response);
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return sb.toString();
}

I need to pass all images to upload to server. 我需要传递所有图像以上传到服务器。 But it's ok only when I pass 9 param.put 但是只有当我通过9 param.put时才可以

您应该考虑使用Retrofit ,它允许分块上传大型文件,并且比大多数库具有更大的灵活性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM