我正在学习 Smalltalk/Seaside,我正在尝试从 REST 服务返回图片。我正在阅读 seaside book关于 REST 服务。 book中有一个例子关于文件上传,但没有关于如何从 REST 服务返回文件 cq 图像的示例。
我找到了 this在这里,但我不知道如何在海边实现这一点(还)。
作为概念证明或“可能可行的最简单的事情”,我想返回我从磁盘读取的图片。因此,我想在网页上显示图像。关于如何做到这一点的任何想法。
最佳答案
它迟到了但仍然(正在研究类似的东西)
创建你的 WARestfullHandler 子类说 ImageGetter 并定义方法
getImage
<get>
<produces: 'image/png'>
| file image |
[
file := (FileSystem workingDirectory / 'myImage.png') readStream binary.
image := file contents ]
ensure: [ file close ].
^ image
现在使用注册端点
WAAdmin register: ImageGetter at: 'images'
在调用 images/getImage 时,您将收到要在浏览器上显示的图像。
以上网址将为您提供更多选项/信息。
关于rest - Smalltalk/海边REST服务返回图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16233639/