[Geoserver-users] Upload a SLD style file into a remote Geoserver

Hi,

I would like to create a new style into my Geoserver from a SLD file.
I used, among other things, these links : http://docs.geoserver.org/latest/en/user/rest/examples/curl.html and http://sourceforge.net/p/geoserver/mailman/message/25127542/ and tried these two commands :

curl -v -u admin:geoserver -XPOST -H “Content-type: text/xml” -d “style_namefile.sld” http://localhost:8080/geoserver/rest/styles

curl -v -u admin:geoserver -XPUT -H “Content-type: application/vnd.ogc.sld+xml” -d @file.sld http://localhost:8080/geoserver/rest/styles/style_name

If the file.sld is locally stored in Geoserver styles directory, I don’t have any problem. But is it possible to use this issue to upload a file.sld to a remote Geoserver ? Indeed, if I write the path of file.sld in -d argument of the first command, it works fine but the second command failed :

curl -v -u admin:geoserver -XPOST -H “Content-type: text/xml” -d “style_name/home/sophie/ownCloud/file.sld ” http://georchestra-mshe.univ-fcomte.fr/geoserver/rest/styles

curl -v -u admin:geoserver -XPUT -H “Content-type: application/vnd.ogc.sld+xml” -d @/home/sophie/ownCloud/file.sld http://georchestra-mshe.univ-fcomte.fr/geoserver/rest/styles/style_name

It returns this error :

Warning: Couldn’t read data from file “/home/sophie/ownCloud/file.sld”, this makes an empty.

Does anybody know the answer ?

Thank you in advance,

···


Sophie MOLLARD

Pôle Géomatique
MSHE C. N. Ledoux (USR 3124)
Université de Franche-Comté
Tél : 03.81.66.53.04

Hi Sophie,

do I understand you correctly: you are trying to upload a local SLD file to a remote GeoServer via REST API, right?

You can do it in one shot with the following command:

curl -v -u admin:geoserver -XPOST -H “Content-type: application/vnd.ogc.sld+xml” -d @Rivers.sld http://:/geoserver/rest/styles?name=Rivers

Where Rivers.sld is a SLD 1.0 file existing on my local file system (and precisely in the directory where I’m running the cURL command). Note the name=Rivers parameter which is telling GeoServer the name of the newly created style.

Hope this helps.

···

On Mon, Jan 25, 2016 at 10:23 AM, Sophie Mollard <sophie.mollard@anonymised.com…> wrote:

Hi,

I would like to create a new style into my Geoserver from a SLD file.
I used, among other things, these links : http://docs.geoserver.org/latest/en/user/rest/examples/curl.html and http://sourceforge.net/p/geoserver/mailman/message/25127542/ and tried these two commands :

curl -v -u admin:geoserver -XPOST -H “Content-type: text/xml” -d “style_namefile.sld” http://localhost:8080/geoserver/rest/styles

curl -v -u admin:geoserver -XPUT -H “Content-type: application/vnd.ogc.sld+xml” -d @file.sld http://localhost:8080/geoserver/rest/styles/style_name

If the file.sld is locally stored in Geoserver styles directory, I don’t have any problem. But is it possible to use this issue to upload a file.sld to a remote Geoserver ? Indeed, if I write the path of file.sld in -d argument of the first command, it works fine but the second command failed :

curl -v -u admin:geoserver -XPOST -H “Content-type: text/xml” -d “style_name/home/sophie/ownCloud/file.sld ” http://georchestra-mshe.univ-fcomte.fr/geoserver/rest/styles

curl -v -u admin:geoserver -XPUT -H “Content-type: application/vnd.ogc.sld+xml” -d @/home/sophie/ownCloud/file.sld http://georchestra-mshe.univ-fcomte.fr/geoserver/rest/styles/style_name

It returns this error :

Warning: Couldn’t read data from file “/home/sophie/ownCloud/file.sld”, this makes an empty.

Does anybody know the answer ?

Thank you in advance,


Sophie MOLLARD

Pôle Géomatique
MSHE C. N. Ledoux (USR 3124)
Université de Franche-Comté
Tél : 03.81.66.53.04


Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Best regards,
Stefano Costa

==
GeoServer Professional Services from the experts! Visit
[http://goo.gl/it488V](http://goo.gl/it488V) for more information.
==
Dott. Stefano Costa
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://www.geo-solutions.it)
[http://twitter.com/geosolutions_it](http://twitter.com/geosolutions_it)

-------------------------------------------------------
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate.
Il loro utilizzo è consentito esclusivamente al destinatario del
messaggio, per le finalità indicate nel messaggio stesso. Qualora
riceviate questo messaggio senza esserne il destinatario, Vi preghiamo
cortesemente di darcene notizia via e-mail e di procedere alla
distruzione del messaggio stesso, cancellandolo dal Vostro sistema.
Conservare il messaggio stesso, divulgarlo anche in parte,
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità
diverse, costituisce comportamento contrario ai principi dettati dal
D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely
for the attention and use of the named addressee(s) and may be
confidential or proprietary in nature or covered by the provisions of
privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New
Data Protection Code).Any use not in accord with its purpose, any
disclosure, reproduction, copying, distribution, or either
dissemination, either whole or partial, is strictly forbidden except
previous formal approval of the named addressee(s). If you are not the
intended recipient, please contact immediately the sender by
telephone, fax or e-mail and delete the information in this message
that has been received in error. The sender does not give any warranty
or accept liability as the content, accuracy or completeness of sent
messages and accepts no responsibility  for changes made after they
were sent or for other risks which arise as a result of e-mail
transmission, viruses, etc.

Problem solved !

We must write the path to file.sld into the second command only.

curl -v -u admin:geoserver -XPOST -H “Content-type: text/xml” -d “style2style2.sldhttp://georchestra-mshe.univ-fcomte.fr/geoserver/rest/styles
This first command creates the style on Geoserver and the file style2.xml in Geoserver styles directory.

curl -v -u admin:geoserver -XPUT -H “Content-type: application/vnd.ogc.sld+xml” -d @/home/sophie/ownCloud/style2.sld http://georchestra-mshe.univ-fcomte.fr/geoserver/rest/styles/style2
This second command upload the characteristics of the local style2.sld into the new style and create the file style2.sld in Geoserver styles directory.

···

Sophie MOLLARD

Pôle Géomatique
MSHE C. N. Ledoux (USR 3124)
Université de Franche-Comté
Tél : 03.81.66.53.04

Le 25/01/2016 10:23, Sophie Mollard a écrit :

Hi,

I would like to create a new style into my Geoserver from a SLD file.
I used, among other things, these links : http://docs.geoserver.org/latest/en/user/rest/examples/curl.html and http://sourceforge.net/p/geoserver/mailman/message/25127542/ and tried these two commands :

curl -v -u admin:geoserver -XPOST -H “Content-type: text/xml” -d “style_namefile.sld” http://localhost:8080/geoserver/rest/styles

curl -v -u admin:geoserver -XPUT -H “Content-type: application/vnd.ogc.sld+xml” -d @file.sld http://localhost:8080/geoserver/rest/styles/style_name

If the file.sld is locally stored in Geoserver styles directory, I don’t have any problem. But is it possible to use this issue to upload a file.sld to a remote Geoserver ? Indeed, if I write the path of file.sld in -d argument of the first command, it works fine but the second command failed :

curl -v -u admin:geoserver -XPOST -H “Content-type: text/xml” -d “style_name/home/sophie/ownCloud/file.sld ” http://georchestra-mshe.univ-fcomte.fr/geoserver/rest/styles

curl -v -u admin:geoserver -XPUT -H “Content-type: application/vnd.ogc.sld+xml” -d @/home/sophie/ownCloud/file.sld http://georchestra-mshe.univ-fcomte.fr/geoserver/rest/styles/style_name

It returns this error :

Warning: Couldn’t read data from file “/home/sophie/ownCloud/file.sld”, this makes an empty.

Does anybody know the answer ?

Thank you in advance,


Sophie MOLLARD

Pôle Géomatique
MSHE C. N. Ledoux (USR 3124)
Université de Franche-Comté
Tél : 03.81.66.53.04

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
[http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140](http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140)
_______________________________________________
Geoserver-users mailing list
[Geoserver-users@lists.sourceforge.net](mailto:Geoserver-users@anonymised.comsourceforge.net)
[https://lists.sourceforge.net/lists/listinfo/geoserver-users](https://lists.sourceforge.net/lists/listinfo/geoserver-users)