abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Re: Specifying Mime Types on Binary data
Date Tue, 11 Sep 2007 14:32:09 GMT
Hello Takasho,

The change you made is not quite right.  We want setDataHandler to get
the content type but we want to allow users the ability to override that
type. So yes, you definitely found a bug but your fix is just a little
off. I can take a look today and get it fixed.

- James

Takasho wrote:
> 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());
> binary.addAuthor("Takasho");
> 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:
> 
> setMimeType(dataHandler.getContentType());
> 
> 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();
>     _removeAllChildren();
>     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.
> 
> Takasho.
> 

Mime
View raw message