Uploading large files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Uploading large files

Colin Putney

On Aug 15, 2007, at 2:16 PM, cnantais wrote:

> So, I changed it to this:
>
> WATempFile>>initializeFromChunk: aChunk
> fileName _ aChunk fileName.
> contentType _ aChunk contentType.
> (self tempDirectory
> forceNewFileNamed: self tempFileName)
> do: [:f | fileSize _ aChunk saveToStream: f]
>
> And it now works, almost.  I'm seeing no increase in memory  
> consumption when
> I submit an upload of a 10mb mp3 file. Only problem is that it is  
> creating
> zero-byte files in the 'tmp' directory when I upload something,  
> like so:

Oops. #forceNewFileNamed:do: is peculiar to my image - that  
definitely won't work in a stock image. I'm surprised that what  
you've got there doesn't throw an error. It should be something like  
this:

WATempFile>>initializeFromChunk: aChunk
        fileName _ aChunk fileName.
        contentType _ aChunk contentType.
        f := self tempDirectory forceNewFileNamed: self tempFileName.
        [fileSize := aChunk saveToStream: f]
                ensure: [f close]

Colin
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Uploading large files

Philippe Marschall
2007/8/19, Colin Putney <[hidden email]>:

>
> On Aug 15, 2007, at 2:16 PM, cnantais wrote:
>
> > So, I changed it to this:
> >
> > WATempFile>>initializeFromChunk: aChunk
> >       fileName _ aChunk fileName.
> >       contentType _ aChunk contentType.
> >       (self tempDirectory
> >               forceNewFileNamed: self tempFileName)
> >               do: [:f | fileSize _ aChunk saveToStream: f]
> >
> > And it now works, almost.  I'm seeing no increase in memory
> > consumption when
> > I submit an upload of a 10mb mp3 file. Only problem is that it is
> > creating
> > zero-byte files in the 'tmp' directory when I upload something,
> > like so:
>
> Oops. #forceNewFileNamed:do: is peculiar to my image - that
> definitely won't work in a stock image. I'm surprised that what
> you've got there doesn't throw an error. It should be something like
> this:

Why is #do: on the class side and part of the selector? Putting it on
the instance side would make it work with all the instance creation
methods without duplication.

Cheers
Philippe

> WATempFile>>initializeFromChunk: aChunk
>         fileName _ aChunk fileName.
>         contentType _ aChunk contentType.
>         f := self tempDirectory forceNewFileNamed: self tempFileName.
>         [fileSize := aChunk saveToStream: f]
>                 ensure: [f close]
>
> Colin
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Uploading large files

cnantais
In reply to this post by Colin Putney
Thanks, Colin.

It's working, however it is taking about 60 seconds to upload a 5mb mp3 file and up to 98% of my CPU.  Then the temp file actually ends up being larger than the original by about 20% and is corrupt. It's the same for mp3s, images, other binary types, but not text files.

Chad

Colin Putney wrote
On Aug 15, 2007, at 2:16 PM, cnantais wrote:

> So, I changed it to this:
>
> WATempFile>>initializeFromChunk: aChunk
> fileName _ aChunk fileName.
> contentType _ aChunk contentType.
> (self tempDirectory
> forceNewFileNamed: self tempFileName)
> do: [:f | fileSize _ aChunk saveToStream: f]
>
> And it now works, almost.  I'm seeing no increase in memory  
> consumption when
> I submit an upload of a 10mb mp3 file. Only problem is that it is  
> creating
> zero-byte files in the 'tmp' directory when I upload something,  
> like so:

Oops. #forceNewFileNamed:do: is peculiar to my image - that  
definitely won't work in a stock image. I'm surprised that what  
you've got there doesn't throw an error. It should be something like  
this:

WATempFile>>initializeFromChunk: aChunk
        fileName _ aChunk fileName.
        contentType _ aChunk contentType.
        f := self tempDirectory forceNewFileNamed: self tempFileName.
        [fileSize := aChunk saveToStream: f]
                ensure: [f close]

Colin
_______________________________________________
Seaside mailing list
Seaside@lists.squeakfoundation.org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
12