Upload file in Android with outofmemory error

后端 未结 2 619
孤独总比滥情好
孤独总比滥情好 2021-01-26 04:00

My upload code as below:

String end = \"\\r\\n\";
String twoHyphens = \"--\";
String boundary = \"*****\";
try {
URL url = new URL(ActionUrl);
HttpURLConnection          


        
2条回答
  •  悲&欢浪女
    2021-01-26 04:40

    brian, you should add

    con.setChunkedStreamingMode(0);
    

    before

    DataOutputStream ds = new DataOutputStream(con.getOutputStream());
    

    if your server could support chunked mode, or add

    con.setFixedLengthStreamingMode(packet_size);
    

    where packet_size = upload_file_size + header_size.

提交回复
热议问题