[Seaside] How to save a html5 canvas.toDataURL as a png file on the server

Bob N. bobn at rogers.com
Wed Jul 27 15:43:55 UTC 2011


Thanks. Here is what I'm now using...

html jQuery ajax
callback: [:value |
| writestream |
writestream := (('c:\data\sketchpad_', Time now asSeconds printString
,'.png') asFilename withEncoding:  #binary) writeStream.
[writestream nextPutAll: (Seaside.GRPlatform current base64Decode: value)
asByteArray] ensure: [writestream close]]
value: (Javascript.JSStream on: 'sketchpadCanvas.toDataURL()')

...but I got an exception in Net.MimeScanner
class>>decodeBase64From:to:in:on:

aString size is 17074 and the code iterates over the string, checking a
#limit which is set to the string size. But the code checks for index + 3
which exceeds the string size.  Hacking the code so the limit is set to size
- 3 works, but the resulting image is not a valid PNG file.

Is there is way to test the decoded content to see if it is a valid PNG
file?

I also tried toDataURL("image/jpeg") which created an output starting with
'data:image/jpeg;base64' but that also saved an invalid image file.

Bob

On Wed, Jul 27, 2011 at 10:23 AM, Philippe Marschall <
philippe.marschall at gmail.com> wrote:

> 2011/7/27 Bob N. <bobn at rogers.com>:
> > Thanks Johan, feels like I almost have it.
> > I'm doing this work in VW. Could someone show the VW equivalent of
> > #base64Decoded? Or is it in some Seaside compatibility library? I'm using
> > 'Seaside 3.0 - 87' from the Cincom public repository.
>
> GRPlatform current base64Decode:
>
> Cheers
> Philippe
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20110727/1924078c/attachment-0001.htm


More information about the seaside mailing list