我曾经通过像这样的图片传递参数来进行thpput调用httpput with param
现在,我想像这样的照片与身体binay methode改变httpput身体二进制
我在iOS中找到了解决方案:
[request setHTTPBody: dataToUpload];
我需要Android中的解决方案。非常感谢
好吧,您必须设置适当的内容类型,例如application/octet-stream
,将内容写入连接输出流。
conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true); // Allow Outputs
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/octet-stream");
outputStream = connection.getOutputStream();
outputStream.writeBytes(lineEnd);
outputStream.close();
这将传输原始的二进制数据,如果要上传文件,请检查https://reecon.wordpress.com/2010/04/04/25/uploading-files-files-to-http-server-using-server-using-server-Android-SDK/