2013-04-26 46 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

上面的網址會給你更多的選項/信息。

相關問題