我曾经通过传递像这张照片的参数来进行thhpput调用 httpput with param
现在我想像这张照片一样改变身体binay方法 httpput body binary
我在ios中找到了解决方案:
[request setHTTPBody: dataToUpload];
我需要Android中的解决方案。非常感谢
答案 0 :(得分:0)
好吧,您必须设置适当的内容类型,例如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/25/uploading-files-to-http-server-using-post-android-sdk/