Ok, well I forgot to add the part for the upload side.
Again the issue on the iphone is uploading 50MB files, but for
desktop, what if someone wants to push 1GB file?
anyway first you have to turn on the KOM stream uploading feature, say
via
WAKom default streamUploads: true.
now the issue is with
MAFileUploadCompoent>>upload: aFile
self value: (aFile isNil ifFalse: [
self description kind new
mimetype: aFile contentType;
filename: aFile fileName;
contents: aFile contents;
yourself ])
That sets the content to "aFile contents".
I changed that to
MAFileUploadComponent>>upload: aFile
self value: (aFile isNil ifFalse: [
self description kind new
mimetype: aFile contentType;
filename: aFile fileName;
contentsFromWATemporaryFileProxy: aFile;
yourself ])
MAFileModel>>contentsFromWATemporaryFilePRoxy: file
self contents: file contents
and
MAExternalFileModel>>contentsFromWATemporaryFileProxy: file
| writeStream readStream |
"Write Stream is a file handle to the Pier storage library, Read
Stream will be the WATemporaryFile"
"Set instance filesave value, and copy file from temporary storage to
Pier storage"
writeStream := self writeStream.
readStream := file stream.
filesize := readStream size.
[FileDirectory default copyFile: readStream toFile: writeStream]
ensure:
[readStream close.
writeStream close]
and
WATemporaryFile>>stream
| stream |
stream := self temporaryDirectory readOnlyFileNamed: self
temporaryFileName.
stream binary.
^stream
I note however on the iPhone I do this instead of the copyFile:toFile:
IPhoneWikiServerUI isiPhone
ifTrue: [IPhoneWikiServerUI move: readStream to: writeStream.
^self].
and use an operating system call to move the file from one directory
to the other so the cost is zero, when WATemporaryFileProxy
closes, it runs out the delete the file, but we've move it, guess I
should add an override...
BTW In Sophie we coded up a os-x api call to either copy or move files
via OS calls so we could preserve all the file meta-data.
Doing the copyFile: toFile: is just so *primitive* and expensive.
Now if someone want's to test all this that would be great because my
environment is contaminated with changes and it's a bit hard to
confirm I"ve detailed all the changes.
We've attempted to mark all our Magrritte/pier/seaside changes as
overrides or extensions, but it's easy to miss one or two.
Testing in fact is easy on a desktop machine, for linux based
machines you would start the VM with a memory configuration of oh say
40MB depending on your pier image. On the Macintosh make a copy of the
squeak.app and change the info.plist SqueakMaxHeapSize entry from
536870912 to 40000000, or you can start the VM on the cmd line (see
http://wiki.squeak.org/squeak/105)
and set -memory 40m just like you would do on Linux.
This will limit the VM to use 40MB of memory, now attempt to add an
image file of say 50MB to a pier page. No doubt you should use the GC/
memory report to confirm what you think you are telling the VM about
memory upper bound is what it actually is don.g
On 19-Apr-09, at 2:12 PM, Lukas Renggli wrote:
I integrated
the change with Magritte-Seaside-lr.295, however instead
of using the standard
WADocumentHandler of Seaside I added my own
handler called MAFileModelHandler. Like this I don't think I need to
worry about ascii/binary modes (AFAIK) and I can avoid unnecessary
copy and cache operations that the default implementation idoes.
Furthermore it does not depend on platform dependent file operations,
something I would like to avoid if possible (for GST, VisualWorks and
GemStone compatibility).
Please give it a try and let me know if this solves at least the
current problems when the file is served through the image.
Cheers,
Lukas
--
Lukas Renggli
http://www.lukas-renggli.ch
--
=
=
=
========================================================================
John M. McIntosh <johnmci(a)smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd.
http://www.smalltalkconsulting.com
=
=
=
========================================================================