RESTful方式的文件上传
我想使用 openrasta 以 RESTful 方式实现文件上传,但无法找到正确的方法来实现它。我能找到的方法很少,例如使用 Ajax 文件上传或使用 Iframe。
任何人都可以建议任何方法来做到这一点,或者为我提供一些我可以参考的资源。
提前致谢
I want to implement file upload in RESTful way using openrasta but not able to find proper way to implement it.There are few ways like using Ajax file upload or using Iframe which i could find.
Can anybody suggest any way of doing this or provide me some resources from where i can refer.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,你正在尝试在 html 环境中构建文件上传。
你有两个选择。
使用 HTML 表单上传文件。
您可以非常轻松地将其映射到 OR 中。您的处理程序将如下所示:
您无法使用进度条执行基于 ajax 的文件上传,因为纯 xmlhttprequest 中无法操作二进制文件。如果您在后台使用 flash/silverlight 控件,则只需确保将文件的内容发布到
/files
,如前面的示例所示,这是最简单的方式是使用 application/octet-stram 的 Content-Type http 标头发送内容,并且相同的处理程序代码将正常工作。It seems to me you're trying to build file uploading in an html environment.
You have two choices.
Use an HTML form to upload the file.
You can map that in OR very easily. Your handler would look like this:
You can't do ajax-based file upload with progress bars as there is no way in pure xmlhttprequest to manipulate binary files. If you go down the route of using a flash / silverlight control behind the scene, you'll just need to make sure you post the content of the file to
/files
as in the previous example, the easiest way being to send the content with a Content-Type http header of application/octet-stram, and the same handler code will just work.