Thanks very much, putting the datastream content directly in the POSTed messaged worked. You're correct, you should use the appropriate Content-Type header override. To include an external file in the POST, you can use '@' to prepend the file's path, as illustrated below:
curl -H "Content-Type: application/x-zip-compressed" --data-binary @test.zip http://localhost:8080/fedora/objects/marktest:1/datastreams/testmanagedzip?controlGroup=M Mark ----- Original Message ----- > If I'm not mistaken you should be posting the XML directly (using the > cURL flag "--data-binary") to: > > http://localhost:8080/fedora/objects/marktest:1/datastreams/testmanagednewxml?controlGroup=M&dsLabel=NewManagedDatastream > > and you can abandon the "-T" flag entirely. You want the datastream > contents -in- the POST message, not as an upload file, and the query > string as part of your URL. E.g. > > curl --data-binary "<my XML data/>" > http://localhost:8080/fedora/objects/marktest:1/datastreams/testmanagednewxml?controlGroup=M&dsLabel=NewManagedDatastream > > or > > curl --data-binary @my/xml/filepath > http://localhost:8080/fedora/objects/marktest:1/datastreams/testmanagednewxml?controlGroup=M&dsLabel=NewManagedDatastream > > You may also need to include a content-type header, e.g. > > -H "Content-Type: text/xml" > > --- > A. Soroka > Digital Research and Scholarship R & D > the University of Virginia Library > > > > On Oct 24, 2010, at 1:49 PM, Mark Jordan wrote: > > > Hi, > > > > I'm using the REST API via cURL on OS X (Fedora 3.4.1) to add and > > update managed datastreams. Updating an existing datastream composed > > of a simple XML file works fine: > > > > curl -v -u fedoraAdmin:xxxxxxx -T testmanaged.xml > > "http://localhost:8080/fedora/objects/marktest:1/datastreams/testmanagedxml" > > > > However, adding a new datastream (using a file of any format as the > > DS) throws the following error: > > > > "javax.ws.rs.WebApplicationException: > > org.fcrepo.server.errors.GeneralException: Error with uploaded://15 > > : XML was not well-formed. Premature end of file." (Note: Integer at > > end of "Error with uploaded" increments on every attemp.) > > > > catalina.out also contains corresponding "[Fatal Error] :-1:-1: > > Premature end of file." entries. > > > > Example cURL requests that cause Fedora to throw this error: > > > > curl -v -u fedoraAdmin:xxxxx -T testmanagednew.xml -X POST -d > > "controlGroup=M&dsLabel=NewManagedDatastream" > > "http://localhost:8080/fedora/objects/marktest:1/datastreams/testmanagednewxml" > > > > and: > > > > curl -v -u fedoraAdmin:xxxxxx -X POST -d > > "controlGroup=M&dsLabel=NewManagedDatastream&dsLocation=http://localhost/testmanagednew.xml" > > "http://localhost:8080/fedora/objects/marktest:1/datastreams/testmanagednewxml" > > > > and even with when using a ZIP file as a datastream: > > > > curl -v -u fedoraAdmin:xxxxx -X POST -d > > "controlGroup=M&dsLabel=NewManagedDatastream&dsLocation=http://localhost/test.zip" > > "http://localhost:8080/fedora/objects/marktest:1/datastreams/testmanagednewZIP" > > > > When I use the Fedora Web Administrator to create a new managed > > datastream using the same files, everything works (e.g., the > > datastream is created and Fedora doesn't complain about a malformed > > XML file). The XML files I trying to add as datastreams pass xmllint > > well-formedness tests, but as my attempt with using a ZIP file to > > create the DS shows, I don't think the XML files are at fault. > > > > I'm not sure if this is a cURL error (i.e., it's munging the > > uploaded file somehow), an error in my use of cURL, or a problem > > with Fedora. My platform is Mac OS X, my cURL is version 7.21.0, and > > my Fedora 3.4.1 install is a quickinstall using all defaults. > > > > Any assistance would be appreciated, > > > > Mark > > > > ------------------------------------------------------------------------------ > > Nokia and AT&T present the 2010 Calling All Innovators-North America > > contest > > Create new apps & games for the Nokia N8 for consumers in U.S. and > > Canada > > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > > marketing > > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi > > Store > > http://p.sf.net/sfu/nokia-dev2dev > > _______________________________________________ > > Fedora-commons-users mailing list > > Fedora-commons-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/fedora-commons-users > > > ------------------------------------------------------------------------------ > Nokia and AT&T present the 2010 Calling All Innovators-North America > contest > Create new apps & games for the Nokia N8 for consumers in U.S. and > Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi > Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > Fedora-commons-users mailing list > Fedora-commons-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/fedora-commons-users ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Fedora-commons-users mailing list Fedora-commons-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fedora-commons-users