abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Takasho <taka...@gmail.com>
Subject Specifying Mime Types on Binary data
Date Tue, 11 Sep 2007 10:59:08 GMT
Hi All,

I have been trying to specify mime types on binary data, specifically in the
following example:

//Add a binary entry
Entry binary = factory.newEntry();
binary.setText("Perfect Day");
binary.setUpdated(new Date());
URL url = Create.class.getResource("podcast.mp3");
binary.setContent(new DataHandler(new URLDataSource(url)), "audio/mpeg3");

After running this it create the entry but sets the binary entry to have
"content/unknown" as the type e.g.

<content type="content/unknown">

After lots of debugging it is set in FOMContent.java in the setDataHandler
method. Which calls:


Which uses the dataHandler to try and retrieve the mime type. It comes back
"content/unknown" and that is then set on the content.

I changed the setDataHandler method to:

public void setDataHandler(DataHandler dataHandler) {
    if (!Type.MEDIA.equals(type)) throw new IllegalArgumentException();
    addChild(factory.createOMText(dataHandler, true));

And now i get the correct mime type set on my binary object e.g.

<content type="audio/mpeg3">

I'm not entirely sure if that was the best thing to do but it has solved my
problem for now.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message