You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@abdera.apache.org by James M Snell <ja...@gmail.com> on 2007/09/11 22:37:38 UTC

Re: Specifying Mime Types on Binary data

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.
> 

Re: Specifying Mime Types on Binary data

Posted by Takasho <ta...@gmail.com>.
Hi James,

That's fixed it. I now get the correct mime type passed through. Thanks.

Takasho

On 11/09/2007, James M Snell <ja...@gmail.com> wrote:
>
> 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
>
>