为此,您可以使用
TypedByteArray
您的翻新服务将如下所示:
@POST("/send")void upload(@Body TypedInput bytes, Callback<String> cb);
您的客户代码:
byte[] byteArray = ... TypedInput typedBytes = new TypedByteArray("application/octet-stream", byteArray); remoteService.upload(typedBytes, new Callback<String>() { @Override public void success(String s, Response response) { //Success Handling } @Override public void failure(RetrofitError retrofitError) { //Error Handling } });
“应用程序/八位字节流”-代替此MIME-
TYPE,您可能要使用数据格式类型。您可以在这里找到详细信息:http : //www.freeformatter.com/mime-types-
list.html
和Spring MVC控制器(如果需要):
@RequestMapping(value = "/send", method = RequestMethod.POST)public ResponseEntity<String> receive(@RequestBody byte[] data) { //handle data return new ResponseEntity<>(HttpStatus.CREATED);}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)