4

I need to automatically (using python) upload a shapefile into my geoserver.

I'm trying to do as described in here but i'm getting this error:

java.io.IOException: Wrong magic number, expected 9994, got 1347093252* Connection #0 to host localhost left intact

I'm sending this:

curl -u admin:geoserver -v -XPUT -H 'Content-type: application/zip' --data-binary @C:/x/test_data/localfile.zip http://localhost:8081/geoserver/rest/workspaces/test_VN/datastores/maisum/file.shp
R.K.
17.5k3 gold badges61 silver badges110 bronze badges
asked Nov 27, 2012 at 10:36
2
  • what is the actual request you are sending? Commented Nov 27, 2012 at 10:45
  • iant, check my edit in the question. Commented Nov 27, 2012 at 10:53

2 Answers 2

3

I take it you're using Windows? Could you try using double quotes instead of single quotes?

curl -u admin:geoserver -v -XPUT -H "Content-type: application/zip" \
 --data-binary @C:/x/test_data/localfile.zip \ 
 http://localhost:8081/geoserver/rest/workspaces/test_VN/datastores/maisum/file.shp

I think the problem is that Windows is ignoring the Content type as it's enclosed in single quotes. Therefore, Geoserver does not treat the file as zip. From the Windows command shell documentation:

... any argument that contains spaces or begins or ends with spaces must be enclosed in double quotes. This is particularly important when using long file and directory names, which frequently contain one or more spaces. If a double-quoted argument itself contains a double quote character, the double quote must be doubled. For example, enter "Quoted" Argument as """Quoted"" Argumen


(削除)

Found this at the Geoserver mailing list.

Sometimes after repeated failed uploads some files can linger around on the server that cause problems. Go to your GEOSERVER_DATA_DIRECTORY and remove any lingering files from the "data" directory under it. Then try again.

Hopefully, that should help solve your problem.

(削除ここまで)

answered Nov 27, 2012 at 11:54
8
  • hmm, no luck. I still got the same problem. Commented Nov 27, 2012 at 12:15
  • Oh, what version of Geoserver are you using btw? And have you ever successfully uploaded a file or is this your first attempt? Commented Nov 27, 2012 at 12:24
  • I uploaded a lot of files but not programaticaly. first time with that. My geoserver is v2.2.2 Commented Nov 27, 2012 at 12:26
  • Updated my answer. I think it's the quotes that did it. Commented Nov 27, 2012 at 12:35
  • Glad to be of help :) Commented Nov 27, 2012 at 14:03
0

even if the answer is already found i would like to point to an nice article about adding layers to Geoserver using curl for the users who are still searching for some more information about that: http://boundlessgeo.com/2012/10/adding-layers-to-geoserver-using-the-rest-api/

answered Jan 28, 2015 at 12:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.