From: Jon G. <jon...@gm...> - 2007-12-11 16:44:34
|
Hey, I just realized I could look at the source for the xmldb:store xquery function. It casts the Resource to an ExistResource and calls setMimeType() on it. Sorry for sending out my question prematurely. Would it be a reasonable feature request to have Collection.storeResource() look up the mime type using the mime-types.xml file? I assume that is what the Java admin client is doing. Thanks, Jon On Dec 11, 2007 9:30 AM, Jon Gunnip <jon...@gm...> wrote: > Hi, > > How does one set the mime type of a BinaryResource through the XMLDB > API? I see it is exposed through the xquery function xmldb:store: > http://demo.exist-db.org/xquery/functions.xq#xmldb:store. The only > potential method I saw in the XMLDB API was Resource.setProperty(). > > I'm adding an .xqm file that should be stored as application/xquery, > but it gets stored with type application/octet-stream when storing via > the XMLDB API. I've pasted my code below. When I store the file > through the admin client, the mime-type is set properly. > > I'm using 1.1.2dev revision 4311. > > Thanks, > Jon > > public void saveNonXmlDocument(String id, String collectionName, > String document) { > Collection collection = getCollection(collectionName); > BinaryResource resource = (BinaryResource) > collection.createResource(id, "BinaryResource"); > resource.setContent(document); > collection.storeResource(resource); > } > |