I use importer rest api.
So:
step 1: POST   /geoserver/rest/imports (specifying target workspace and
target datastore) to obtain an importID
step2: POST    /geoserver/rest/imports/<importID>/tasks (passing zip file
into body) to obtain a taskID (zip is uploaded into geoserver data dir and
is unzipped)
step3: PUT      /geoserver/rest/imports/<importID>/tasks/<taskID>/target
to reset the target store for given taskID
step4: POST    /geoserver/rest/imports/<importID> to execute import

This sequence of operations create a table named as passed shapefile into
given workspace/datastore;
if a table with same name already exists, created table is renamed
appending number.

If between step2 and step3 I execute PUT
geoserver/rest/imports/<importID>/tasks/<taskID>
passing
{
  "layer": {
    "name": "layer1",
    "title": "layer1"
  }
}
I could rename layer on geoserver with a different name than that of the
table.

If between step2 and step3 I execute PUT
geoserver/rest/imports/<importID>/tasks/<taskID>
passing
{
  "task": {
     "updateMode": "APPEND"
  }
}
I could append data into existing table (named as uploaded shapefile)

I can't find a way to insert data from uploaded shapefile shape.shp into a
table which is called tableA (with same fields obviously)

It's possible?
Thanks

Giuseppe




Il giorno mar 10 mag 2022 alle ore 06:33 Jody Garnett <
jody.garn...@gmail.com> ha scritto:

> You may also consider using the resource rest api to upload the file, and
> the the importer rest api in ingest (it offers greater control as Ian
> suggests).
>
> The upload you found determines a unique table name based on the provided
> content, so for your shapefile this is based on the filename.
>
> The file is here
> https://github.com/geoserver/geoserver/blob/main/src/restconfig/src/main/java/org/geoserver/rest/catalog/DataStoreFileController.java
>  if
> you wish to troubleshoot.
>
>                     // does the feature type already exist in the target?
>                     try {
>                         targetDataStore.getSchema(featureTypeName);
>                     } catch (Exception e) {
>                         LOGGER.info(
>                                 featureTypeName
>                                         + " does not exist in data store "
>                                         + storeName
>                                         + ". Attempting to create it");
>
>                         // schema does not exist, create it by first
> creating an instance
>                         // of the source datastore and copying over its
> schema
>
> targetDataStore.createSchema(sourceDataStore.getSchema(featureTypeName));
>                         sourceDataStore.getSchema(featureTypeName);
>                     }
>
> --
> Jody Garnett
>
>
> On May 9, 2022 at 10:34:22 AM, Giuseppe Falcone <
> falcone.giuse...@gmail.com> wrote:
>
>> Hi
>> thanks for the response.
>> I'm building a web application that must have this function.
>> From browser user upload a shapefile e I put into a db table.
>> I think REST API are perfect for this purpose.
>>
>> Giuseppe
>>
>> Il giorno lun 9 mag 2022 alle ore 19:22 Ian Turton <ijtur...@gmail.com>
>> ha scritto:
>>
>>> I'm not sure that you need to involve geoserver in this, Ogr2ogr would
>>> be quicker and easier to append a shapefile to a database. The GeoServer
>>> rest api is for creating data stores and layers etc not individual data
>>> management.
>>>
>>> Alternatively you might be able to use the importer extension to do this
>>> but I've not used that in anger
>>>
>>>
>>> Ian
>>>
>>> On Mon, 9 May 2022, 17:25 Giuseppe Falcone, <falcone.giuse...@gmail.com>
>>> wrote:
>>>
>>>> Hi to all
>>>> I want with geoserver REST API put a shapefile into an existing postgis
>>>> table.
>>>> I know how to load a shapefile into a postgis database, but I don't
>>>> know how I could indicate a specific table in which append data.
>>>> I Have a shapefile named tableA.shp; it's possible put it's data into a
>>>> postgis table named tableB?
>>>> Thanks a lot
>>>>
>>>> Giuseppe
>>>>
>>>> _______________________________________________
>>>> Geoserver-users mailing list
>>>>
>>>> Please make sure you read the following two resources before posting to
>>>> this list:
>>>> - Earning your support instead of buying it, but Ian Turton:
>>>> http://www.ianturton.com/talks/foss4g.html#/
>>>> - The GeoServer user list posting guidelines:
>>>> http://geoserver.org/comm/userlist-guidelines.html
>>>>
>>>> If you want to request a feature or an improvement, also see this:
>>>> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>>>>
>>>>
>>>> Geoserver-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>>>
>>> _______________________________________________
>> Geoserver-users mailing list
>>
>> Please make sure you read the following two resources before posting to
>> this list:
>> - Earning your support instead of buying it, but Ian Turton:
>> http://www.ianturton.com/talks/foss4g.html#/
>> - The GeoServer user list posting guidelines:
>> http://geoserver.org/comm/userlist-guidelines.html
>>
>> If you want to request a feature or an improvement, also see this:
>> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>>
>>
>> Geoserver-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>
>
_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


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

Reply via email to