[Geoserver-users] REST PUT to upload files from client machine

All,

I am trying to find a way for the users to upload files such as GeoTiff,
kml, etc. from client machine onto GeoServer workspace and wondering whether
I can use GeoServer REST PUT operation for that.

Below is an example of the REST PUT operation using curl taken from
GeoServer's REST examples.

curl -v -u admin:geoserver -XPUT -H "Content-type: application/zip"
  --data-binary @roads.zip

http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads/file.shp

I known that "@roads.zip" indicates the zip file to be uploaded. But where
is the file? Is it it relative to some path?
and what is the last line? Is it always "http://localhost:8080/geoserver"?
I could not find any examples from the internet showing how to use REST PUT
to upload files from client machine. Can some clarify this? If it can be
done with GeoServer REST API, I greatly appreciated an example in curl.

Many thanks in advance.

Tam

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/REST-PUT-to-upload-files-from-client-machine-tp5103281.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Hi Tam,

···

2014-02-12 6:04 GMT+01:00 tt5430 <tt9488@anonymised.com>:

All,

I am trying to find a way for the users to upload files such as GeoTiff,
kml, etc. from client machine onto GeoServer workspace and wondering whether
I can use GeoServer REST PUT operation for that.

Below is an example of the REST PUT operation using curl taken from
GeoServer’s REST examples.

curl -v -u admin:geoserver -XPUT -H “Content-type: application/zip”
–data-binary @roads.zip

http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads/file.shp

I known that “@roads.zip” indicates the zip file to be uploaded. But where
is the file? Is it it relative to some path?

It is relative to the path you are launching curl from. You can also specify an absolute path.

and what is the last line? Is it always “http://localhost:8080/geoserver”?

It is the url of the geoserver you need to configure with the new shapefile. That one is the default url when you install the standalone geoserver locally on your PC.
Do you have a geoserver installed on some server?

I could not find any examples from the internet showing how to use REST PUT
to upload files from client machine. Can some clarify this? If it can be
done with GeoServer REST API, I greatly appreciated an example in curl.

On the same page you found the shapefile example (http://docs.geoserver.org/latest/en/user/rest/examples/curl.html), you can find other examples for other types of data.
In this other documentation page (http://docs.geoserver.org/latest/en/user/rest/) you can find a reference for all the supported rest requests. For example to upload a geotiff you will need a coveragestore PUT request.

Cheers,
Mauro

Hi Mauro,

Thanks for you help. I tried to upload a kml file from a local machine to geoserver installed on other machine and got errors that I don’t know why. Below was what I did:

  1. I created a workspace named “kmls” using:
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml"
  -d "<workspace><name>kmls</name></workspace>"
  [http://172.16.203.30:8080/geoserver/rest/workspaces](http://172.16.203.30:8080/geoserver/rest/workspaces)

2. cd to a directory where that kml file is located.

3. executed the following curl command:
$ curl -v -u admin:geoserver -XPUT -H "Content-type: text/xml" -d @BalloonLinks.kml [http://172.16.203.30:8080/geoserver/rest/workspaces/kmls/datastores/kmls/file.xml](http://172.16.203.30:8080/geoserver/rest/workspaces/kmls/datastores/kmls/file.xml)

* timeout on name lookup is not supported
* About to connect() to 172.16.203.30 port 8080 (#0)
*   Trying 172.16.203.30...
* connected
* Connected to 172.16.203.30 (172.16.203.30) port 8080 (#0)
* Server auth using Basic with user 'admin'

> PUT /geoserver/rest/workspaces/kmls/datastores/kmls/file.xml HTTP/1.1
> Authorization: Basic YWRtaW46Z2Vvc2VydmVy
> User-Agent: curl/7.26.0
> Host: [172.16.203.30:8080](http://172.16.203.30:8080)

> Accept: */*
> Content-type: text/xml
> Content-Length: 7583
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 400 Bad Request
< Server: Apache-Coyote/1.1
< Content-Type: text/plain

< Transfer-Encoding: chunked
< Date: Wed, 12 Feb 2014 16:16:07 GMT
< Connection: close
<
Unsupported format: xml* we are done reading and this is set to close, stop send
* Closing connection #0

What did I do wrong?

Regards,

-Tam


···

On Wed, Feb 12, 2014 at 4:12 AM, Mauro Bartolomeoli-3 [via OSGeo.org] <[hidden email]> wrote:

Hi Tam,

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax:
+39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it



Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience. Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk


Geoserver-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users


If you reply to this email, your message will be added to the discussion below:
http://osgeo-org.1560.x6.nabble.com/REST-PUT-to-upload-files-from-client-machine-tp5103281p5103352.html
To unsubscribe from REST PUT to upload files from client machine, click here.
NAML

2014-02-12 6:04 GMT+01:00 tt5430 <[hidden email]>:

All,

I am trying to find a way for the users to upload files such as GeoTiff,
kml, etc. from client machine onto GeoServer workspace and wondering whether
I can use GeoServer REST PUT operation for that.

Below is an example of the REST PUT operation using curl taken from
GeoServer’s REST examples.

curl -v -u admin:geoserver -XPUT -H “Content-type: application/zip”
–data-binary @roads.zip

http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads/file.shp

I known that “@roads.zip” indicates the zip file to be uploaded. But where
is the file? Is it it relative to some path?

It is relative to the path you are launching curl from. You can also specify an absolute path.

and what is the last line? Is it always “http://localhost:8080/geoserver”?

It is the url of the geoserver you need to configure with the new shapefile. That one is the default url when you install the standalone geoserver locally on your PC.
Do you have a geoserver installed on some server?

I could not find any examples from the internet showing how to use REST PUT
to upload files from client machine. Can some clarify this? If it can be
done with GeoServer REST API, I greatly appreciated an example in curl.

On the same page you found the shapefile example (http://docs.geoserver.org/latest/en/user/rest/examples/curl.html), you can find other examples for other types of data.
In this other documentation page (http://docs.geoserver.org/latest/en/user/rest/) you can find a reference for all the supported rest requests. For example to upload a geotiff you will need a coveragestore PUT request.

Cheers,
Mauro

Don’t think you can upload a kml as far as i know it is supported as output format only.
Try with a shp file instead.
Cheers,
Carlo

···

On Wed, Feb 12, 2014 at 4:12 AM, Mauro Bartolomeoli-3 [via OSGeo.org] <[hidden email]> wrote:

Hi Tam,

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax:
+39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it



Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience. Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk


Geoserver-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users


If you reply to this email, your message will be added to the discussion below:
http://osgeo-org.1560.x6.nabble.com/REST-PUT-to-upload-files-from-client-machine-tp5103281p5103352.html
To unsubscribe from REST PUT to upload files from client machine, click here.
NAML

2014-02-12 6:04 GMT+01:00 tt5430 <[hidden email]>:

All,

I am trying to find a way for the users to upload files such as GeoTiff,
kml, etc. from client machine onto GeoServer workspace and wondering whether
I can use GeoServer REST PUT operation for that.

Below is an example of the REST PUT operation using curl taken from
GeoServer’s REST examples.

curl -v -u admin:geoserver -XPUT -H “Content-type: application/zip”
–data-binary @roads.zip

http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads/file.shp

I known that “@roads.zip” indicates the zip file to be uploaded. But where
is the file? Is it it relative to some path?

It is relative to the path you are launching curl from. You can also specify an absolute path.

and what is the last line? Is it always “http://localhost:8080/geoserver”?

It is the url of the geoserver you need to configure with the new shapefile. That one is the default url when you install the standalone geoserver locally on your PC.
Do you have a geoserver installed on some server?

I could not find any examples from the internet showing how to use REST PUT
to upload files from client machine. Can some clarify this? If it can be
done with GeoServer REST API, I greatly appreciated an example in curl.

On the same page you found the shapefile example (http://docs.geoserver.org/latest/en/user/rest/examples/curl.html), you can find other examples for other types of data.
In this other documentation page (http://docs.geoserver.org/latest/en/user/rest/) you can find a reference for all the supported rest requests. For example to upload a geotiff you will need a coveragestore PUT request.

Cheers,
Mauro