[GIS] How to upload a NETCDF to Geoserver using cURL

curlgeoserverimage-mosaicnetcdf

I'm trying to upload a NETCDF file (.nc) to Geoserver Store of Coverage ImageMosaic
The command is this:

curl -v -u admin:geoserver -XPOST -H "Content-type: text/plain" 
-d "file:///data/coverages/myNetcdf.nc"
"http://410.152.23.128:8080:8080/geoserver/rest/workspaces/mygis/coveragestores/...
/external.imagemosaic"

as shown in Geoserver 2.4.0 documentation, but I get this message:

* About to connect() to 410.152.23.128 port 8080 (#0)
*   Trying 410.152.23.128...
* Adding handle: conn: 0x94df50
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x94df50) send_pipe: 1, recv_pipe: 0
* Connected to 410.152.23.128 (410.152.23.128:8080) port 8080 (#0)
* Server auth using Basic with user 'admin'
> POST /geoserver/rest/workspaces/mygis/coveragestores/.../external.imagemosaic 
HTTP/1.1
> Authorization: Basic YWRtaW46TYVvc2VydmVy
> User-Agent: curl/7.32.0
> Host: 410.152.23.128:8080
> Accept: */*
> Content-type: text/plain
> Content-Length: 31
>
* upload completely sent off: 31 out of 31 bytes
< HTTP/1.1 400 Bad Request
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Date: Wed, 25 Sep 2013 15:48:37 GMT
< Connection: close
<
Failed to locate the input file file:/data/coverages/myNetcdf.nc* Closing connectio
n 0

the file EXISTS instead,
do u know how to fix this issue? is there another way to upload NetCDF files in ImageMosaic Stores? Plugin of Geoserver 2.4.0 doesn't select my file
thanx in advance

Best Answer

You cannot upload any file with your cURL code. Becasue it sends "Content-type: text/plain" data not a file to the server. GeoServer accepts uploading files in zip (binary) with this "Content-type: application/zip". So you must try this code (change file path, name etc. for your system)

curl -v -u admin:geoserver -XPUT -H "Content-type: application/zip" --data-binary @F:\temporary\testnetcdf.zip http://192.168.79.42/geoserver/rest/workspaces/msb/coveragestores/testnetcdf/file.netcdf

Also you can easily upload GeoTIFF, ImageMosaic or another formats. But you must change file extension in the end of the code. For example file.netcdf to file.geotiff

Another important thing is firstly you have to install NetCDF plugin. Otherwise you get Unsupported format error.

Related Question