[Seaside] What alternative for fileUpload with WAFile for large
files?
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
WATemporaryFile
versus
WAFile
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.
MAFileUploadComponet>>upload: aFile
"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;
contentsFromWATemporaryFilePRoxy: aFile;
yourself ])
The helper methods then do contentsFromWATemporaryFilePRoxy
MAExternalFileModel>>contentsFromWATemporaryFilePRoxy: file
| writeStream readStream |
writeStream := self writeStream.
readStream := file stream.
filesize := readStream size.
[FileDirectory default copyFile: readStream toFile: writeStream] ensure:
[readStream close.
writeStream close]
MAFileModel>>contentsFromWATemporaryFilePRoxy: file
self contents: file contents
The next issue was the data coming back and in urlOn: it would super to MAFileModel which would do
urlOn: html
^ html context
urlForDocument: self contents
mimeType: self mimetype
fileName: self filename
"Again self contents"
I altered the subclass then to do:
MAExternalFileModel>>urlOn: html
^ self baseUrl isNil
ifTrue: [html context
urlForDocument: self
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
MAExernalFileModel>>asMIMEDocumentType: mimeType
^self readStream asMIMEDocumentType: mimeType
On 2010-03-24, at 1:57 AM, Göran Krampe wrote:
> Hi!
>
> Van Upboy wrote:
>> Hello,
>> 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:
>
> http://lists.squeakfoundation.org/pipermail/seaside/2008-August/018509.html
>
> ...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
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
--
===========================================================================
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...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2445 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/seaside/attachments/20100324/8ef698bc/smime-0001.bin
More information about the seaside
mailing list