Newbie : How can you store an image in a database
Newbie : How can you store an image in a database
- Subject: Newbie : How can you store an image in a database
- From: Gilles MATHURIN <email@hidden>
- Date: Sat, 17 Jun 2006 12:35:00 -0400
I'm newbie in wo. I use OpenBase and i have a database with those
entities :
Artist (firstname, name and photoID)
Album (Title, Date of realease)
Title (songTitle, Lenght)
How can i upload and image in the attribute photoID of my Artist
Table. this attribute is defined as a object in EOModeler, with
NSData for Value class. I used a web component with a WOFileUpload
and a Submit button like this :
FileUpload2: WOFileUpload {
data = aFileContents;
filePath = aFileName;
mimeType = aMimeType;
}
SubmitButton2: WOSubmitButton {
action = addToDB;
}
And here is my Main class :
import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;
public class Main extends WOComponent {
protected NSData aFileContents;
protected String aFileName;
protected String aMimeType;
protected Artiste artiste;
public Artiste artisteItem;
public Main(WOContext context) {
super(context);
}
public WOComponent addToDB() {
EOEditingContext ec = session().defaultEditingContext();
artisteItem.setPhotoID(aFileContents);
ec.saveChanges();
return null;
}
public Artiste artiste()
{
return artiste;
}
public void setArtiste(Artiste newArtiste)
{
artiste = newArtiste;
}
public Artiste artisteItem()
{
return artisteItem;
}
public void setArtisteItem(Artiste newArtisteItem)
{
artisteItem = newArtisteItem;
}
}
What's wrong ?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden