我使用GeoServer REST API成功创建了工作区。但我上传形状文件时遇到问题。
我关注this指南。
curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary "@D:/trash.zip" http://localhost:9090/geoserver/rest/workspaces/string/datastores/trash/file.shp
PHP - 等效
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:9090/geoserver/rest/workspaces/string/datastores/trash/file.shp");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$post = array(
"file" => "@" .realpath("D:/trash.zip")
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_USERPWD, "admin" . ":" . "geoserver");
$headers = array();
$headers[] = "Content-Type: application/zip";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
当我跑步时,我得到:
java.lang.RuntimeException:java.io.IOException:错误的幻数, 预计9994,得到757935405
不知道如何将shapefile上传到geoserver。 谢谢!