[Seaside] Re: What alternative for fileUpload with WAFile for large
files?
Van Upboy
van.upboy at gmail.com
Wed Mar 24 20:16:05 UTC 2010
Hi John,
Thanks for this information. My head is spinning right now ;-) but I will
look into it, and probably ask more questions if I understand this better.
Van.
Date: Wed, 24 Mar 2010 11:27:07 -0700
> From: John M McIntosh <johnmci at smalltalkconsulting.com>
> Subject: Re: [Seaside] What alternative for fileUpload with WAFile for
> large files?
> To: Seaside - general discussion <seaside at lists.squeakfoundation.org>
> Message-ID:
> <DEF8230A-9B70-4B4C-BEFC-E0D28BA0F6F9 at smalltalkconsulting.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20100324/1ac9a6d4/attachment.htm
More information about the seaside
mailing list