[Seaside] WAFileLibrary / Resource Path

Philippe Marschall philippe.marschall at gmail.com
Tue Aug 14 17:46:35 UTC 2007


2007/8/14, Martin Kobetic <mkobetic at cincom.com>:
> I apologize for quoting Philippe out of context here, but we've been looking at the issue of uploading/dowloading large files via Seaside recently and my conclusion is that especially for downloading it's not really Seaside's problem to handle. It's for the associated HTTP server to worry about. To test that we can stream downloaded files directly into the socket, all I did was add a subclass of WAFileLibrary and overrode documentAt:ifAbsent: as follows:
>
> WAExternalFileLibrary>>documentAt: aFilename ifAbsent: aBlock
>
>         | fn |
>         fn := '.' asFilename construct: aFilename.
>         ^fn exists
>                 ifTrue: [ | mimeType |
>                         mimeType := self mimetypeForFile: aFilename.
>                         WAResponse new
>                                 contentType: (mimeType ifNil: ['application/octet-stream']);
>                                 headerAt: 'Expires' put: 'Thu, 01 Jan 2095 12:00:00 GMT';
>                                 stream: fn readStream;
>                                 yourself ]
>                 ifFalse: [ aBlock value ]
>
> Ignore the hardwired directory for the moment. With this I could hit  http://localhost:7777/seaside/go/files/WAExternalFileLibrary/visual.im and the 11M image file was downloaded pretty much instantly with the browser and server on the same host.

That's true. WAFileLibrary is a simple solution for simple problems.
It doesn't work. Handling "big" files in Seaside is generally
discouraged. We prefer to leave it to traditional file servers like
Apache or lighy which are optimized for this task. This also takes
load off your Smalltalk Image.

> The key is that we build a WAResponse here with an external stream in it, and the rest is handled by the HTTP server. Am I missing something from the bigger picture ?

Depends on whether you server adaptor supports output streaming.

Cheers
Philippe

> Thanks,
>
> Martin
>
> Philippe Marschall wrote:
> > An other is that serving big files over Seaside is not recommended and we can't tell
> > you where the limit is to the size of files Seaside can serve.
> > Deployment of resources is an issue that needs to be solved at the
> > Smalltalk or version control level.
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>


More information about the Seaside mailing list