[Seaside] Serving pictures from the image

saza solutions fzak at sazasolutions.com
Thu Jan 25 20:16:16 UTC 2007

I did the following.
  Firstly I initialized the gifs. I could do this because my gifs are fixed, I don´t need dynamic files:
 |gifs imagekey newGif|
 gifs:= (FileDirectory on: 'C:\SES\product\squeak 3.8\working\img') fileNamesMatching: '*.gif'.
 gifs do: [:gif |
  imagekey:= ('DES-',(gif copyUpTo: $.)) asSymbol.
  newGif:= (FileStream readOnlyFileNamed: 'C:\SES\product\squeak 3.8\working\img\' , gif) reset; binary; contents.
    ScriptingSystem formDictionary at: imagekey put: (newGif)].
  where 'C:\SES\product\squeak 3.8\working\img' is a path in the server context.
  Then to use them:
  MyWAHtmlRenderer>>getImage: anImageName withPath: aPath
 |imagekey newForm|
 imagekey:= ('DES-',(anImageName copyUpTo: $.)) asSymbol.
 (ScriptingSystem formAtKey: imagekey) isNil
  ifTrue: [newForm:= (FileStream readOnlyFileNamed: ((FileDirectory default pathName),'\', aPath,'\',anImageName)) reset; binary; contents.
    ScriptingSystem formDictionary at: imagekey put: (newForm).
 ^self imageWithForm: (ScriptingSystem formAtKey: imagekey).
  and also override...
  MyWAHtmlRenderer>>imageWithForm: aForm
 self image: (self context urlForDocument: aForm)
  and defined:
 ^MIMEDocument contentType: 'image/gif' content: self 

Jens Pall <jens at axonspace.com> escribió:
  Bany, Michel wrote:
>> Regarding the files, I am looking for a way to serve binary 
>> data from directly within the image itself, not using files 
>> on the external filesystem. I'm planning on using Magma as 
>> the persistent repository for everything and don't want to 
>> rely on stuff out on the filesystem, hence I need a way to 
>> load and serve my images completely from within squeak.
> You may want something like this
> (html anchor)
> document: aByteArray 
> mimeType: 'application/msword' 
> fileName: 'report.doc'

Yes, this looks promising.

But how do I load the document from disk into aByteArray? I think I can 
do this using a web form, but I want to be able to load it directly from 
the filesystem (used in a batch load later).

Seaside mailing list
Seaside at lists.squeakfoundation.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20070125/e9b102d3/attachment.htm

More information about the Seaside mailing list