如何在 Restlet 中将 Representation 转换为 FileRepresentation
我正在使用 Restlet 框架。我创建了一个将文件返回给客户端的 Web 服务。
在服务器端,我首先创建一个 FileRepresentation 对象,正确实例化它,并将其作为 Representation 返回给客户端。
在客户端,我想提取Representation的内容,如何将Representation对象转换为FileRepresentation?
提前致谢!!
I am using Restlet framework. I create one web service that returns a file to the client.
On the server side, I first create a FileRepresentation object, instantiate it correctly, and return it to the client as Representation.
On the client side, I want to extract the content of the Representation, how can I cast the Representation object to FileRepresentation?
Thanks in advance!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,提供 FileRepresentation 类是为了填充文件中的请求/响应,但不能用于提取响应的内容。
要在客户端访问您的响应内容,这取决于文件类型。如果您收到 ascii 内容,您可以执行以下操作:
如果它是二进制文件,则需要使用流,如下所述:
希望它对您有帮助,
蒂埃里
In fact, the FileRepresentation class is provided in order to fill request / response from a file but can't be used to extract content of a response.
To have access to your response content on the client side, it depends on the file type. If you receive an ascii content, you can do something like that:
If it's a binary file, you need to work with a stream, as described below:
Hope it helps you,
Thierry