• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Newbie : How can you store an image in a database
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Newbie : How can you store an image in a database
      • From: " Kuon - Nicolas Goy (Goyman.com SA) - 時期精霊 " <email@hidden>
  • Prev by Date: Re: Problem with webobject attributes in WOBuilder
  • Next by Date: Re: Problems with building WebService
  • Previous by thread: [ OT ] Report on other WO like tools.
  • Next by thread: Re: Newbie : How can you store an image in a database
  • Index(es):
    • Date
    • Thread