[Geoserver-users] How to upload shapefile in Geoserver using php REST API?

Dear Friends:
url = "http://localhost:8080/geoserver/rest/workspaces/ChinaMap/datastores/newPoint/file.shp?charset=GB2312&target=shp&configure=all";
filePath = “E:\newLayerFile/newPoint.zip”;
curl_easy_setopt(_curl_handle, CURLOPT_USERPWD, userPassword.c_str());
curl_easy_setopt(_curl_handle, CURLOPT_URL, url.c_str());
struct stat fileInfo;
stat(filePath.c_str(), &fileInfo);
FILE* hd_src = fopen(filePath.c_str(), “rb”);
if(hd_src)
{
curl_easy_setopt(_curl_handle, CURLOPT_PUT, 1);
curl_easy_setopt(_curl_handle, CURLOPT_UPLOAD, 1);
curl_easy_setopt(_curl_handle, CURLOPT_HEADER, 1);
headers = curl_slist_append(NULL, “Conten-Type: application/zip”);
curl_easy_setopt(_curl_handle, CURLOPT_INFILE, hd_src);
curl_easy_setopt(_curl_handle, CURLOPT_INFILESIZE, (curl_off_t)fileInfo.st_size);
}
curl_easy_setopt(_curl_handle, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(_curl_handle, CURLOPT_VERBOSE, 1);
curl_easy_perform(_curl_handle);

Using the upper function, I can create new store successfully in geoserver2.3.x and geoserver2.4.x. In geoserver2.3.x the new store’s features can be locked, but in geoserver2.4.x the new store’s features can not be locked. So I think whether creating a new store has some problem, or in geoserver2.4.x has some difference from geoserver2.3.x.

Please note that GeoServer 2.4.x is no longer in production. Are you able to test the 2.6-RC1?

There is also an optional importer extension which allows files to be uploaded and unpacked via REST.

···

Jody Garnett

On Tue, Aug 26, 2014 at 7:34 PM, fanxing926 <fanxing926@anonymised.com> wrote:

Dear Friends:
url = "http://localhost:8080/geoserver/rest/workspaces/ChinaMap/datastores/newPoint/file.shp?charset=GB2312&target=shp&configure=all";
filePath = “E:\newLayerFile/newPoint.zip”;
curl_easy_setopt(_curl_handle, CURLOPT_USERPWD, userPassword.c_str());
curl_easy_setopt(_curl_handle, CURLOPT_URL, url.c_str());
struct stat fileInfo;
stat(filePath.c_str(), &fileInfo);
FILE* hd_src = fopen(filePath.c_str(), “rb”);
if(hd_src)
{
curl_easy_setopt(_curl_handle, CURLOPT_PUT, 1);
curl_easy_setopt(_curl_handle, CURLOPT_UPLOAD, 1);
curl_easy_setopt(_curl_handle, CURLOPT_HEADER, 1);
headers = curl_slist_append(NULL, “Conten-Type: application/zip”);
curl_easy_setopt(_curl_handle, CURLOPT_INFILE, hd_src);
curl_easy_setopt(_curl_handle, CURLOPT_INFILESIZE, (curl_off_t)fileInfo.st_size);
}
curl_easy_setopt(_curl_handle, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(_curl_handle, CURLOPT_VERBOSE, 1);
curl_easy_perform(_curl_handle);

Using the upper function, I can create new store successfully in geoserver2.3.x and geoserver2.4.x. In geoserver2.3.x the new store’s features can be locked, but in geoserver2.4.x the new store’s features can not be locked. So I think whether creating a new store has some problem, or in geoserver2.4.x has some difference from geoserver2.3.x.


Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/


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

Cool - be sure to keep emailing the user list, have you tried looking for updated documentation on uploading a shapefile?

You may also have enough information to create a bug report.

···

Jody Garnett

On Tue, Aug 26, 2014 at 10:49 PM, fanxing926 <fanxing926@anonymised.com> wrote:

I don not test 2.6-RC1, but I test the 2.5.x, the problem is the same to the 2.4.x.
Thank you!

At 2014-08-27 01:36:56, “Jody Garnett” <jody.garnett@anonymised.com> wrote:

Please note that GeoServer 2.4.x is no longer in production. Are you able to test the 2.6-RC1?

There is also an optional importer extension which allows files to be uploaded and unpacked via REST.

Jody Garnett

On Tue, Aug 26, 2014 at 7:34 PM, fanxing926 <fanxing926@anonymised.com> wrote:

Dear Friends:
url = "http://localhost:8080/geoserver/rest/workspaces/ChinaMap/datastores/newPoint/file.shp?charset=GB2312&target=shp&configure=all";
filePath = “E:\newLayerFile/newPoint.zip”;
curl_easy_setopt(_curl_handle, CURLOPT_USERPWD, userPassword.c_str());
curl_easy_setopt(_curl_handle, CURLOPT_URL, url.c_str());
struct stat fileInfo;
stat(filePath.c_str(), &fileInfo);
FILE* hd_src = fopen(filePath.c_str(), “rb”);
if(hd_src)
{
curl_easy_setopt(_curl_handle, CURLOPT_PUT, 1);
curl_easy_setopt(_curl_handle, CURLOPT_UPLOAD, 1);
curl_easy_setopt(_curl_handle, CURLOPT_HEADER, 1);
headers = curl_slist_append(NULL, “Conten-Type: application/zip”);
curl_easy_setopt(_curl_handle, CURLOPT_INFILE, hd_src);
curl_easy_setopt(_curl_handle, CURLOPT_INFILESIZE, (curl_off_t)fileInfo.st_size);
}
curl_easy_setopt(_curl_handle, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(_curl_handle, CURLOPT_VERBOSE, 1);
curl_easy_perform(_curl_handle);

Using the upper function, I can create new store successfully in geoserver2.3.x and geoserver2.4.x. In geoserver2.3.x the new store’s features can be locked, but in geoserver2.4.x the new store’s features can not be locked. So I think whether creating a new store has some problem, or in geoserver2.4.x has some difference from geoserver2.3.x.


Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/


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