Android的凌空发布二进制体 [英] android volley posting binary body

查看:191
本文介绍了Android的凌空发布二进制体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景 - 上传二进制数据在后的身体,处理包含一个JSON响应体。

Scenario - upload binary data in the body of a post, handle a response body containing JSON.

如何做到以下使用凌空?

How to do the following using Volley?

 curl -X  POST  -H "X-Application-Id: 3KxPB" -H "X-REST-API-Key: jkuI9"  -H "Content-Type: audio/3gp"  --data-binary '@test.3gp' https://host/1/files/audio

IMO - 没有在凌空处理二进制POST主体类型阿帕奇HttpClient的处理中的 abstracthttpentity 。如果手机通过摄像头,麦克风,或其他二进制输出传感器上产生缓冲的二进制数据,需要一个机制来包裹并写入POST的身体如何做到在凌空?

IMO - there is a gap in Volley handling binary POST body types that apache httpclient handles in subclasses of abstracthttpentity. If buffered binary data generated on the phone by camera, microphone, or other binary output sensors needs a mechanism to be wrapped and written to the body of a POST how to do it in volley?

我看了<一个href=\"https://android.googlesource.com/platform/frameworks/volley/+/9e5c44f22b47fcb0d37c7b10de3b5db542424fa5/src/com/android/volley/toolbox/PoolingByteArrayOutputStream.java\"相对=nofollow> PoolingByteArrayOutputStream 并希望像做填充缓冲区并得到PBAOutStrm,从缓冲区写入PBAOutStrm,然后翻转OutStrm到InputStream中,然后在POST请求的身体包起来有点像ByteArrayEntity。我看不出如何做到这一点的凌空抽射。

I've looked at PoolingByteArrayOutputStream and would like to do something like fill the buffer and get the PBAOutStrm ,writing to PBAOutStrm from the buffer and then flipping OutStrm to InputStream and then wrap it in the body of a POST request as something like a ByteArrayEntity. I cant see how to do that in volley.

推荐答案

要发送你可以做一些二进制数据,就像我在这个答案没有<一个href=\"http://stackoverflow.com/questions/16797468/how-to-send-a-multipart-form-data-post-in-android-with-volley/16803473#16803473\">How送的multipart / form-data的POST Android中使用凌空。

To send binary data you can do something like what I did in this answer How to send a "multipart/form-data" POST in Android with Volley .

这篇关于Android的凌空发布二进制体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆