Thanks. Nice catch. <div>Adjusting the string also avoids the VW index range error in Net.MimeScanner class&gt;&gt;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 := (&#39;c:\data\sketchpad_image.png&#39; 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: &#39;sketchpadCanvas.toDataURL()&#39;));</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>with: &#39;Save&#39;.</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">&lt;<a href="mailto:johan@inceptive.be">johan@inceptive.be</a>&gt;</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&#39;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, &quot;Bob N.&quot; &lt;<a href="mailto:bobn@rogers.com" target="_blank">bobn@rogers.com</a>&gt; wrote:<br><br></div><div></div>
<blockquote type="cite"><div>Thanks. Here is what I&#39;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 := ((&#39;c:\data\sketchpad_&#39;, Time now asSeconds printString ,&#39;.png&#39;) 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: &#39;sketchpadCanvas.toDataURL()&#39;)</div></div><div><br></div><div>...but I got an exception in Net.MimeScanner class&gt;&gt;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(&quot;image/jpeg&quot;) which created an output starting with &#39;data:image/jpeg;base64&#39; 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">&lt;<a href="mailto:philippe.marschall@gmail.com" target="_blank"></a><a href="mailto:philippe.marschall@gmail.com" target="_blank">philippe.marschall@gmail.com</a>&gt;</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. &lt;<a href="mailto:bobn@rogers.com" target="_blank"></a><a href="mailto:bobn@rogers.com" target="_blank">bobn@rogers.com</a>&gt;:<br>

<div>&gt; Thanks Johan, feels like I almost have it.<br>
&gt; I&#39;m doing this work in VW. Could someone show the VW equivalent of<br>
&gt; #base64Decoded? Or is it in some Seaside compatibility library? I&#39;m using<br>
&gt; &#39;Seaside 3.0 - 87&#39; 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>