[Seaside] How-to upload and view image ?

Hilaire Fernandes hilaire at ext.cri74.org
Sun Sep 19 00:21:14 CEST 2004


Thanks a lot for the tips! 

To which Squeak objet match the content in the WAFile? The inspector
says it is a string. Is there any possibility to convert it to another
format to retrieve information concerning the picture.

I have to admit that I am a bit disapointed regarding the over complicated
procedure to just upload a simple picture. Not to say that Mime type
and width and height still  need to be calculated from somewhere.

Regards,

Hilaire

On Sat, 11 Sep 2004 14:49:53 +0200
Andreas Nilsson <wahboh at mac.com> wrote:

  > I just went through this so I'll try to explain what I did to get it 
  > working:
  > 
  > First the upload form:
  > html attributeAt: 'enctype' put: 'multipart/form-data'.
  > html form: [	
  > 	html fileUploadWithCallback: [:file | picture := file contents ].
  > 	html submitButton.
  > ].
  > You get a WAFile in the block parameter so you can look in that class 
  > for ideas, among other things it contains the content type.
  > 
  > Then to display the picture you have to wrap it in a class that 
  > responds to #height, #width, #asMIMEDocument and returns unique values 
  > in #= and #hash for different pictures (otherwise the images will be 
  > cached, ie. they will not change when you change the contents of your 
  > wrapper instance). #height and #width are just used for displaying so 
  > they don't have to match the pictures properties, but it will strech / 
  > shrink if they don't.
  > I implemented asMIMEDocument in the following way in my wrapper class 
  > (APicture):
  > 
  > #asMimeDocument
  > 	^ MIMEDocument contentType: 'image/jpeg' content: contents.
  > 
  > Where contents is the contents from the form above that I passed to the 
  > wrapper instance when I created it.
  > 
  > Then to display it you just pass an instance of your wrapper class 
  > (APicture) to html's #imageWithForm method:
  > 
  > html imageWithForm: picture
  > 
  > Hope that helps!
  > 
  > /Adde
  > 
  > On 2004-09-11, at 14.28, Hilaire Fernandes wrote:
  > 
  > > Hello,
  > >
  > > I am a total newbie both to Seaside and Squeak (and more generaly to 
  > > Smalltalk).
  > >
  > > I try to figure out how an user can upload an image into Seaside, then
  > > how to use it in web page rendering.
  > >
  > > A code example to understand that will be more than enought.
  > >
  > > I saw the WAUploadTest class but I miss the second part where you want 
  > > to use
  > > the uploaded image to render the image in a web document.
  > >
  > > Thanks
  > >
  > > Hilaire
  > > _______________________________________________
  > > Seaside mailing list
  > > Seaside at lists.squeakfoundation.org
  > > http://lists.squeakfoundation.org/listinfo/seaside
  > 
  > _______________________________________________
  > Seaside mailing list
  > Seaside at lists.squeakfoundation.org
  > http://lists.squeakfoundation.org/listinfo/seaside
  > 


More information about the Seaside mailing list