[Seaside] What alternative for fileUpload with WAFile for large
John M McIntosh
johnmci at smalltalkconsulting.com
Wed Mar 24 18:27:07 UTC 2010
Ah, it shouldn't run out of memory.
Wikiserver for the iPhone uses an older version of Pier and I and to make a few changes (which were fed back to the Pier folks) to ensure
it could stream up/down 50MB files on a device within a 10 MB free memory footprint.
However the support isn't quite turned on or accessible by default.
You have to do
WAKomEncoded default streamUploads: true.
which then alters a decision to use
The original email for this is below, but the implementation that was done by the Pier team is different.
Ok in order to get streaming to work, so that I could upload and see a 58MB TIFF image on a remote browser from the iphone wikiserver but use no more than 30MB of memory I had do the following:
Well turn it on: WAKom default streamUploads: true.
"First this did contents: aFile contents which won't work with 800MB files,
"Alter to execute a method that takes the aFile"
self value: (aFile isNil ifFalse: [
self description kind new
mimetype: aFile contentType;
filename: aFile fileName;
The helper methods then do contentsFromWATemporaryFilePRoxy
| writeStream readStream |
writeStream := self writeStream.
readStream := file stream.
filesize := readStream size.
[FileDirectory default copyFile: readStream toFile: writeStream] ensure:
self contents: file contents
The next issue was the data coming back and in urlOn: it would super to MAFileModel which would do
^ html context
urlForDocument: self contents
mimeType: self mimetype
fileName: self filename
"Again self contents"
I altered the subclass then to do:
^ self baseUrl isNil
ifTrue: [html context
mimeType: self mimetype
fileName: self filename]
ifFalse: [ self baseUrl , '/' , (self location reduce: [ :a :b | a , '/' , b ]) , '/' , self filename ]
Lastly we need to keep the logic from creating a mime document and caching the contents, rather
we need to create a localfilemimedocment by doing
^self readStream asMIMEDocumentType: mimeType
On 2010-03-24, at 1:57 AM, Göran Krampe wrote:
> Van Upboy wrote:
>> I'm using fileUpload (seaside 2.8), which uses a WAFile to store the contents directly. However, this doesn't work for (very) large files, because pharo will run out of memory. Likewise, an anchor like this:
>> html anchor
>> document: aWAFile contents
>> mimeType: aWAFile contentType
>> fileName: aWAFile fileName;
>> with: aWAFile fileName.
>> won't work, because I can't serve the content directly from memory.
>> I'm new to SmallTalk & Seaside, and I'm wondering how I should approach this problem?
> I posted a changeset a long while back that adds streaming upload
> directly to disk:
> ...it was a while since I played with that, not sure what status we have
> today regarding Seaside and SocketStream in your particular image.
> regards, Göran
> seaside mailing list
> seaside at lists.squeakfoundation.org
John M. McIntosh <johnmci at smalltalkconsulting.com> Twitter: squeaker68882
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2445 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/seaside/attachments/20100324/8ef698bc/smime-0001.bin
More information about the seaside