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 20:37:38 GMT
I've checked in a fix and re-generated the 0.3.0 candidate zips. It
would be helpful if you could verify the fix with your code.

- 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