FWIW: I tried saving the contents of the JSStream string directly in Pharo and I get an invalid PNG file.<div><br></div><div><div>| string |</div><div>string := &#39;data:image/png;base64... &#39;. &quot;long string from toDataURL()&quot;</div>
<div>(FileStream newFileNamed: (&#39;c:\data\sketchpad_test.png&#39;)) binary nextPutAll: string base64Decoded </div><div><br></div><div>Bob</div><br><div class="gmail_quote">On Wed, Jul 27, 2011 at 4:19 AM, 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 style="word-wrap:break-word">I also responded this on stack overflow.<div><br></div><div><span style="border-collapse:collapse;font-family:Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif;font-size:14px;line-height:18px"><p style="margin-top:0px;margin-right:0px;margin-bottom:1em;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:14px;vertical-align:baseline;background-color:transparent;clear:both;word-wrap:break-word;background-repeat:initial initial">
Depending on how you want your website to behave, I guess there are multiple ways of doing it. Here is the raw sample of one possibility I can think of using a jQuery ajax callback:</p><pre style="margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:5px;padding-right:5px;padding-bottom:5px;padding-left:5px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:14px;vertical-align:baseline;background-color:rgb(238, 238, 238);font-family:Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif;overflow-x:auto;overflow-y:auto;width:auto;max-height:600px;background-repeat:initial initial">
<code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:14px;vertical-align:baseline;background-color:rgb(238, 238, 238);font-family:Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif;background-repeat:initial initial">html jQuery ajax 
callback: [:value | (FileStream newFileNamed: &#39;test.png&#39;) nextPutAll: value base64Decoded ] 
value: (JSStream on: &#39;canvas.toDataURL()&#39;)
</code></pre><p style="margin-top:0px;margin-right:0px;margin-bottom:1em;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:14px;vertical-align:baseline;background-color:transparent;clear:both;word-wrap:break-word;background-repeat:initial initial">
I did not test this myself. Maybe the filestream needs to be sent the <code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:1px;padding-right:5px;padding-bottom:1px;padding-left:5px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:14px;vertical-align:baseline;background-color:rgb(238, 238, 238);font-family:Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif;background-repeat:initial initial">#binary</code> message to make a correct png file. Let me know if there are troubles.</p>
<p style="margin-top:0px;margin-right:0px;margin-bottom:1em;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:14px;vertical-align:baseline;background-color:transparent;clear:both;word-wrap:break-word;background-repeat:initial initial">
Hope it helps.</p></span><div><div><div></div><div class="h5"><div>On 26 Jul 2011, at 22:01, Bob N. wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div class="h5">(I also posted this in stack overflow)<div>
<br></div><div><div>I have an image that users can annotate on the browser. I can access the image using</div><div>    canvas.toDataURL() </div><div>...I&#39;d like to add a &#39;save&#39; option for the user to save the image on the server.</div>

<div><br></div><div>This question has been answered for php...</div><div>    file_put_contents(&#39;test.png&#39;, base64_decode(substr($data, strpos($data, &quot;,&quot;)+1))); </div><div>...what I need is a Seaside callback with the PNG file contents.</div>

<div><br></div><div>Is there a way to do this in Seaside?</div></div><div><br></div><div>Thanks,</div><div>Bob </div></div></div>
_______________________________________________<br>seaside mailing list<br><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">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
</blockquote></div><br></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>