2013-04-26 56 views
3

我正在学习Smalltalk/Seaside,我试图从REST服务中返回一张图片。我正在阅读关于REST服务的seaside bookbook上的文件上传中有一个示例,但没有关于如何从REST服务返回文件cq图像的示例。Smalltalk/seaside REST服务返回图像

我在SO上发现了this,但我不知道如何在海边实现这个(还)。

作为一个概念证明或'可能工作的最简单的东西'我想返回一张我从磁盘读取的图片。因此我想在网页上展示图片。任何想法如何做到这一点。

回答

0

较晚,但仍然(正在对类似的东西)

创建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你会收到要在浏览器上显示的图像。

https://code.google.com/p/seaside/wiki/SeasideRest

上面的网址会给你更多的选项/信息。