[Seaside] large files / 2 - WAFile

Michal miso.list at auf.net
Thu Apr 1 07:59:32 CEST 2004

While uploading large files with Seaside's #fileUploadWithCallback:
the image grows in surprising proportions. Uploading a single 3.4MB
pdf file resulted in an image jumping from 40MB to 85MB, for instance.

Calling #clearAllHandlers reclaims the space, and it looks like it all
comes down to a single instance of WAFile which holds onto the string
of the pdf file. I'm inclining towards the following approach to deal
with the issue of multiple people uploading large files. In WAFile

contents: aStream
	aStream size > threshold
		ifTrue: [create-temp-file, nextPutAll: aStream, close it]
		ifFalse: [contents := aStream]

	^ contents ifNil: [read contentsOfEntireTempFile]

	^ contents isNil

This would not only avoid keeping 40MB in memory, but would also allow
the client seaside component to get the file to its final disk
destination by simply moving it there without ever bringing it back to
memory, along the lines of:

aWAFile contentsIsOnDisk 
	ifTrue: [move-it-to-where-i-want-it]
	ifFalse: [create-file, nextPutAll:, clost it]

Comments? Does that sound like a reasonable modification to Seaside's
(large) file handling?


More information about the Seaside mailing list