[Seaside] Integrating Images on a website. Don't want to use
Apache or WAFileLibrary.
Holger Kleinsorgen
kleinsor at smallish.org
Wed Apr 23 19:43:37 UTC 2008
Martin Kobetic schrieb:
> The extension is rather trivial as you can see in the attached file-out.
> It should file into Squeak fine, although there might be some VW
> specific bits in it, so you may have to fix it up for it to actually
> work in Squeak.
Works with some minor tweaking, see attached fileout.
-------------- next part --------------
'From Squeak3.9 of 7 November 2006 [latest update: #7067] on 23 April 2008 at 9:41:54 pm'!
WAFileLibrary subclass: #WAExternalFileLibrary
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'SeasideForOpentalk'!
!WAExternalFileLibrary commentStamp: '<historical>' prior: 0!
This class adds the ability to serve content from files external to the image.
The files go in to a subdirectory from the running directory called 'files'
The URL to access the files is: http://localhost:7777/seaside/files/external/myfile.png
Seaside protects against malicious users attempting to use '..' to access above the 'files' directory.!
!WAExternalFileLibrary methodsFor: 'accessing' stamp: 'hkl 4/23/2008 21:40'!
documentAt: aFilename ifAbsent: aBlock
| fn files mimeType fileStream |
files := FileDirectory default directoryNamed: 'files'.
files exists ifFalse: [^aBlock value].
fn := files fullNameFor: aFilename.
^(files fileOrDirectoryExists: fn)
ifTrue:
[mimeType := self mimetypeForFile: aFilename.
fileStream := (files readOnlyFileNamed: fn) binary.
(WAStreamResponse on: fileStream)
contentType: (mimeType ifNil: ['application/octet-stream']);
headerAt: 'Expires' put: 'Thu, 01 Jan 2095 12:00:00 GMT';
yourself]
ifFalse: [aBlock value]! !
!WAExternalFileLibrary methodsFor: 'accessing' stamp: ' 23/4/08 11:00'!
urlOf: aSymbol using: aHandler
^(aHandler baseUrl)
addToPath: 'external';
addToPath: (self asFilename: aSymbol);
yourself! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
WAExternalFileLibrary class
instanceVariableNames: ''!
!WAExternalFileLibrary class methodsFor: 'testing' stamp: ' 23/4/08 11:00'!
handlesFolder: aSymbol
^aSymbol = #external! !
More information about the seaside
mailing list