All, Thanks for confirming that mimeType isn't supported in REST API-M 3.1. And for all the links to various possible workarounds...I'll look them over and see what is most expedient in my case.
best regards, -Don On 3 March 2010 15:54, Gottwig, Jeremy M. (GSFC-272.0)[ZIMMERMAN & ASSOC.] <[email protected]> wrote: > Might be worth taking at look at the Zend HTTP Client, which comes bundled > with the Zend Framework, which I've found to be a fairly elegant solution > when working in PHP. > > For example, you can set the encoding type like this: > > $client->setRawData($xml)->setEncType('text/xml')->request('POST'); > > The $xml value would house the XML you want to send to Fedora. > > Documentation here: > > http://framework.zend.com/manual/en/zend.http.html > > I've included a quick function below just to demonstrate how it could work > with the REST interface. > > > function goddardlibapi_getnextpid($namespace) > { > $url = > "http://libossils.gsfc.nasa.gov:9000/fedora/objects/nextPID?namespace=" . > $namespace . "&format=xml"; > include_once('Zend/Http/Client.php'); > $client = new Zend_Http_Client($url); > $client->setAuth('username','password'); > $response = $client->request('POST'); > if($response->getStatus() == 200){ > $str = $response->getBody(); > $xml = simplexml_load_string($str); > return (string) $xml->pid; > }else{ > return FALSE; > } > } > 61,4 48% > > -----Original Message----- > From: Chris Wilper [mailto:[email protected]] > Sent: Wednesday, March 03, 2010 3:38 PM > To: Don Gourley > Cc: [email protected] > Subject: Re: [Fedora-commons-users] mimeType not working on add/modify > Datastream REST API > > Hi Don, > > Although this should work in Fedora 3.3, the REST API in Fedora 3.1 > didn't support a mimeType parameter...it always used the one that was > in the request header. > > Compare: > http://fedora-commons.org/documentation/3.1/Fedora%20REST%20API.html > to: > http://www.fedora-commons.org/confluence/display/FCR30/REST+API#RESTAPI-addDatastream > > If you can't upgrade to 3.3, you might try avoiding libcurl and do it > directly: > > http://netevil.org/blog/2006/nov/http-post-from-php-without-curl > > ...not sure how relevant that is these days, and I'm far from > php-savvy, but it may be worth a shot. > > - Chris > > On Wed, Mar 3, 2010 at 2:27 PM, Don Gourley <[email protected]> wrote: >> Thanks Jason, I have tried that and the datastreamVersion I got was: >> >> <foxml:datastreamVersion ID="dctst.4" LABEL="Test Modify" >> CREATED="2010-03-01T20:14:28.119Z" >> MIMETYPE="text/xml;boundary=----------------------------48598ac9f1c5"> >> >> and I also got the boundary and some header stuff mixed in to the top >> of the datastream. So It looks like it is messing up the multipart >> content-type rather than assigning it to the XML part of the request >> content. This post is the best explanation of how PHP/libcurl is >> broken that I've found: >> >> http://osdir.com/ml/web.curl.php/2007-12/msg00033.html >> >> I'm new to PHP, and FedoraCommons, but it seems simpler to use the >> mimeType parameter if I can figure if/how it works. >> >> -Don >> >> On 3 March 2010 14:06, Jason Nugent <[email protected]> wrote: >>> hi Don, >>> >>> Have you tried using the PHP libcurl function curl_setopt() to set the >>> MIME type for your PHP curl call? >>> >>> $header = array(); >>> $header[] = "Content-Type: text/html"; >>> >>> ... other additions to $header, and then: >>> >>> curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); >>> >>> before you do your curl_exec() call. >>> >>> Regards, >>> >>> Jason >>> >>> On 3/3/10 2:49 PM, Don Gourley wrote: >>>> When I add or modify a managed XML datastream using the REST API, I am >>>> unable to get the correct mime-type on the datastreamVersion. For >>>> example, >>>> >>>> curl -i -XPUT >>>> "https://example.com:8443/fedora/objects/demo:29/datastreams/dctst?mimeType=text/xml&controlGroup=M&dsLabel=Test+mimeType" >>>> --data-binary @dc.xml -k -u fedoraAdmin:****** >>>> >>>> creates a datastreamVersion like this: >>>> >>>> <foxml:datastreamVersion ID="dctst.5" LABEL="Test mimeType" >>>> CREATED="2010-03-03T18:10:23.286Z" >>>> MIMETYPE="application/x-www-form-urlencoded"> >>>> <foxml:contentLocation TYPE="INTERNAL_ID" REF="demo:29+dctst+dctst.5"/> >>>> </foxml:datastreamVersion> >>>> >>>> (I've tried it url-encoded with the mimeType=text%2Fxml also) >>>> >>>> I know that I can add -H "Content-Type: text/xml" to the cURL command >>>> and get the right mime-type in the datastreamVersion, but the problem >>>> is that I am trying to write client application using PHP and libcurl >>>> and adding a content-type request header doesn't work with that mix. >>>> And the mimeType parameter is supposed to override the request header >>>> anyway, or am I not using it correctly? >>>> >>>> I am trying to update a Fedora 3.1 repository. >>>> >>>> thanks, >>>> -Don >>>> >>>> ------------------------------------------------------------------------------ >>>> Download Intel® Parallel Studio Eval >>>> Try the new software tools for yourself. Speed compiling, find bugs >>>> proactively, and fine-tune applications for parallel performance. >>>> See why Intel Parallel Studio got high marks during beta. >>>> http://p.sf.net/sfu/intel-sw-dev >>>> _______________________________________________ >>>> Fedora-commons-users mailing list >>>> [email protected] >>>> https://lists.sourceforge.net/lists/listinfo/fedora-commons-users >>>> >>> >>> -- >>> Jason Nugent >>> Systems Programmer/Database Developer >>> Electronic Text Centre >>> University of New Brunswick >>> [email protected] >>> (506) 447 3177 >>> >> >> >> >> -- >> Don Gourley, IT Manager >> Digital Humanities Observatory >> ~a project of the Royal Irish Academy~ >> +353 1 234 2446 -- [email protected] >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Fedora-commons-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/fedora-commons-users >> > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Fedora-commons-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/fedora-commons-users > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Fedora-commons-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/fedora-commons-users > -- Don Gourley, IT Manager Digital Humanities Observatory ~a project of the Royal Irish Academy~ +353 1 234 2446 -- [email protected] ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Fedora-commons-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fedora-commons-users
