Hi,

I've currently got some code which creates a new coveragestore and coverage
using REST.  It doesn't actually upload the coverage, but instead links
Geoserver to its current location on disk.  How would I change this so that
it actually uploads the file to geoserver? My code is shown below (it using
the Jersey REST client).

public static void linkToExternalCoverage(String geoserverUrl, File file,
String workspace, String coverageStoreName, String coverageName) {
 WebResource r = client.resource(geoserverUrl + "/rest/workspaces/"
+ workspace + "/coveragestores");
 try {
// POST coveragestore
String xml = "<coverageStore><name>" + coverageStoreName
 + "</name><workspace>" + workspace
+ "</workspace><enabled>true</enabled></coverageStore>";
 r.type("application/xml").post(String.class, xml);

// PUT coverage
 r = client.resource(geoserverUrl + "/rest/workspaces/" + workspace
+ "/coveragestores/" + coverageName
 + "/external.geotiff?configure=first&coverageName="
+ coverageName);
 r.put(String.class, "file:/" + file.getAbsolutePath());
} catch (UniformInterfaceException e) {
 e.printStackTrace();
}
}

Cheers,

Jon
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to