From: Palmer, E. <ep...@ri...> - 2012-11-09 17:29:09
|
Awesome Sent from my iPhone On Nov 9, 2012, at 8:42 AM, "Michael Jones" <mic...@gm...<mailto:mic...@gm...>> wrote: Thank you to all that helped. I've managed to get it working. For the sake of the group and anyone else researching this problem, here is my solution $data = file_get_contents('/home/me/data/'.$file); $header = array( "Authorization: Basic " . base64_encode('admin' . ':' . 'password'), "Content-Type: text/xml" ); $params = array( 'http' => array( 'method' => 'PUT', 'header' => $header, 'content' => $data) ); $ctx = stream_context_create($params); $response = file_get_contents('http://localhost:8080/exist/rest/db/foo/'.$file, false, $ctx); On Fri, Nov 9, 2012 at 1:14 PM, Palmer, Eric <ep...@ri...<mailto:ep...@ri...>> wrote: typos Sent from my iPad On Nov 9, 2012, at 6:02 AM, "Palmer, Eric" <ep...@ri...<mailto:ep...@ri...>> wrote: > exist re-indexes the file when the write is complete. So this is automatic. > > I don't have access to the exist documentation right now. But the http protocol specifies different modes 9GET, PUT, POST, DELETE...). So in the curl setopts you will tell it that the request is a PUT. You will then supply the url to php curl that points to the rest interface collection and filename of your instance. > > Something like > > http://localhost:8080/exist/rest/db/collectionName/sbuColName/fileName.xml > > > You will supply php curl with either a file name or a string for the source xml. I'm not conversant with php curl so it may be that you have to open the local file (if you have them as files) and read it into a string first. But there a lot of curl put and post examples out there. > > You can also get a plugin for firefox to test the syntax of the url and just get used to how this works and what the response header looks like. > > I use httpRequestor > > https://addons.mozilla.org/en-us/firefox/addon/httprequester/ > > Once you get this working you will see how easy it is. > > > Eric Palmer > Director of Web Services > University of Richmond > ________________________________________ > From: Michael Jones [mic...@gm...<mailto:mic...@gm...>] > Sent: Friday, November 09, 2012 7:30 AM > To: Palmer, Eric; exi...@li...<mailto:exi...@li...> > Subject: Re: [Exist-open] Update/Insert xml to eXist-db > > Thanks. Where should the XML be 'PUT' and how do I trigger exist-db to reindex the files. > > > On Fri, Nov 9, 2012 at 12:09 PM, Palmer, Eric <ep...@ri...<mailto:ep...@ri...><mailto:ep...@ri...<mailto:ep...@ri...>>> wrote: > Yes you can. > > We use Java for that but the same concepts hold. You can use two techniques. > > 1) A http put of the file. In PHP look at curl and the put options. When you do a put the file gets stored directly in the location you specify on the url. > > A http post of the file. When you post you will submit the post data to an xquery that can dispatch it to it's desired location. Using a xquery dispatcher you can log in exist-db the post operation. > > The put is very simple and that is what we use but we have played with the post version as well. > > If you put a file that exists already it is replaced (updated). We do this with a java middleware program to two exist instances. We put 8,000 to 15,000 files a day into exist-db. > > This is a php example for curl php put. Just change the url of the put location. http://www.lornajane.net/posts/2009/putting-data-fields-with-php-curl > > > Eric Palmer > Director of Web Services > University of Richmond > ________________________________________ > From: Michael Jones [mic...@gm...<mailto:mic...@gm...><mailto:mic...@gm...<mailto:mic...@gm...>>] > Sent: Friday, November 09, 2012 6:23 AM > To: exi...@li...<mailto:exi...@li...><mailto:exi...@li...<mailto:exi...@li...>> > Subject: [Exist-open] Update/Insert xml to eXist-db > > Hi group, > > Is it possible to push new xml / update files in exist-db with PHP? > > I've had a look around for an example but the only one I could really find was this http://www.ibm.com/developerworks/library/x-mxd5/ > > Is it possible to batch upload files to eXist with PHP? > > Thanks > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_nov > _______________________________________________ > Exist-open mailing list > Exi...@li...<mailto:Exi...@li...> > https://lists.sourceforge.net/lists/listinfo/exist-open |