使用 REST 发送文件?

发布于 2024-08-08 12:57:31 字数 99 浏览 4 评论 0原文

像 Restlet 和 Jersey 这样的 Java REST 框架是否允许将文件作为输入发送到 Web 服务?

这将包括客户端发送文件,然后服务器接收并处理该文件。

Do Java REST frameworks like Restlet and Jersey allow one to send a file as input to a web service?

This would encompass the client sending the file and the server then receiving and processing the file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甜宝宝 2024-08-15 12:57:31

如果您询问是否可以对 Restlet 服务执行 HTTP PUT,那么,绝对可以。如果您只想存储文件,可以使用 Directory 类,也可以实现自己的 ServerResource 来处理新资源。

我没有使用过 Jersey,但 Restlet 是一个非常棒的 api。

If you're asking if you can do an HTTP PUT to a Restlet service, then, absolutely, yes you can. You can use the Directory class if you just want to store the file, or you can implement your own ServerResource to handle the new resource.

I haven't used Jersey, but Restlet is a fantastic api.

画离情绘悲伤 2024-08-15 12:57:31

嗯,没有限制他们不这样做。 REST 处理文件没有任何问题。
看看:
http://mikedesjardins.us/wordpress/2007/04/restful -ftp 服务/

Well, there's no restriction for them not to do it. REST handles files without any problems.
Take a look at:
http://mikedesjardins.us/wordpress/2007/04/restful-services-on-ftp/

花海 2024-08-15 12:57:31

您还可以使用基于 HTTP 客户端构建的 REST Assured。这很简单:

given().multiPart(new File("/somedir/file.bin")).when().post("/fileUpload");

You can also use REST Assured which builds on HTTP Client. It's very simple:

given().multiPart(new File("/somedir/file.bin")).when().post("/fileUpload");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文