我正在尝试使用 ReSTLet 发送一个 byte[](使用 PUT),但我找不到有关如何执行此操作的任何信息。我的代码如下所示:
Request request = new Request(Method.PUT, url);
request.setEntity( WHAT DO I PUT HERE?, MediaType.APPLICATION_OCTET_STREAM);
我曾期望找到与 ByteArrayRepresentation 类似的东西,就像有一个 JsonRepresentation 和一个 StringRepresentation,但我找不到任何东西。
最佳答案
我相信你想使用 InputRepresentation ,像这样:
Representation representation = new InputRepresentation(new ByteArrayInputStream(bytes), MediaType.APPLICATION_OCTET_STREAM);
request.setEntity(representation);
关于java - 使用 ReSTLet 客户端发送二进制数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/904333/