Thanks. Nice catch. <div>Adjusting the string also avoids the VW index range error in Net.MimeScanner class>>decodeBase64From:to:in:on:<div><br></div><div>This code works in VW (with string copy hack).<div><br></div>
<div><div>html button</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>onClick: (html jQuery ajax </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>callback: [:value | </div><div>
<span class="Apple-tab-span" style="white-space:pre">                                </span>| writestream string | <span class="Apple-tab-span" style="white-space:pre">                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>writestream := ('c:\data\sketchpad_image.png' asFilename withEncoding: #binary) writeStream.</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>string := value copyFrom: 23 to: value size.</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>[writestream nextPutAll: (Seaside.GRPlatform current base64Decode: string) asByteArray] </div>
<div> ensure: [writestream close] ] </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>value: (Javascript.JSStream on: 'sketchpadCanvas.toDataURL()'));</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>with: 'Save'.</div><div><br></div><div>Bob</div><div><br><div class="gmail_quote">On Wed, Jul 27, 2011 at 3:16 PM, Johan Brichau <span dir="ltr"><<a href="mailto:johan@inceptive.be">johan@inceptive.be</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div bgcolor="#FFFFFF"><div>I don't have access to a smalltalk image right now, but my guess is you need to strip the string of the mine type declaration first. The php example does the same thing: it takes the substring after the comma before decoding and writing to the file.<br>
<br>--<div>Johan</div></div><div><div></div><div class="h5"><div><br>On 27 Jul 2011, at 17:43, "Bob N." <<a href="mailto:bobn@rogers.com" target="_blank">bobn@rogers.com</a>> wrote:<br><br></div><div></div>
<blockquote type="cite"><div>Thanks. Here is what I'm now using... <div><br></div><div><div><div>html jQuery ajax </div><div><span style="white-space:pre-wrap">        </span>callback: [:value | </div><div><span style="white-space:pre-wrap">                </span>| writestream | <span style="white-space:pre-wrap">                        </span></div>
<div><span style="white-space:pre-wrap">                </span>writestream := (('c:\data\sketchpad_', Time now asSeconds printString ,'.png') asFilename withEncoding: #binary) writeStream.</div><div><span style="white-space:pre-wrap">                </span>[writestream nextPutAll: (Seaside.GRPlatform current base64Decode: value) asByteArray] ensure: [writestream close]] </div>
<div><span style="white-space:pre-wrap">        </span>value: (Javascript.JSStream on: 'sketchpadCanvas.toDataURL()')</div></div><div><br></div><div>...but I got an exception in Net.MimeScanner class>>decodeBase64From:to:in:on: </div>
<div><br></div><div>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.</div>
<div><br></div><div>Is there is way to test the decoded content to see if it is a valid PNG file?</div><div><br></div><div>I also tried toDataURL("image/jpeg") which created an output starting with 'data:image/jpeg;base64' but that also saved an invalid image file.</div>
<div><br></div><div>Bob </div><br><div class="gmail_quote">On Wed, Jul 27, 2011 at 10:23 AM, Philippe Marschall <span dir="ltr"><<a href="mailto:philippe.marschall@gmail.com" target="_blank"></a><a href="mailto:philippe.marschall@gmail.com" target="_blank">philippe.marschall@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">2011/7/27 Bob N. <<a href="mailto:bobn@rogers.com" target="_blank"></a><a href="mailto:bobn@rogers.com" target="_blank">bobn@rogers.com</a>>:<br>
<div>> Thanks Johan, feels like I almost have it.<br>
> I'm doing this work in VW. Could someone show the VW equivalent of<br>
> #base64Decoded? Or is it in some Seaside compatibility library? I'm using<br>
> 'Seaside 3.0 - 87' from the Cincom public repository.<br>
<br>
</div>GRPlatform current base64Decode:<br>
<br>
Cheers<br>
<font color="#888888">Philippe<br>
</font><div><div></div><div>_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org" target="_blank"></a><a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank"></a><a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
</div></div></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>seaside mailing list</span><br><span><a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a></span><br>
<span><a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a></span><br></div></blockquote></div></div></div><br>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
<br></blockquote></div><br></div></div></div></div>