Skip to main content
Question

How to upload a shapefile or geotiff to geoserver with FME


How to upload a shapefile or geotiff to geoserver with FME

6 replies

xiaomengatsafe
Safer
Forum|alt.badge.img+3

Hi @abeklaas, Welcome to FME Community Forum! Thanks for posting your first question!

It looks like GeoServer has an API, which makes me think we can use FME's HTTPCaller to upload files. Here is the documentation on their API, https://docs.geoserver.org/stable/en/user/rest/. Once you are familiar with the API, and find the appropriate endpoint for uploading files, FME can definitely help.

We have an article that might give you an overall introduction to API and how FME works with them:

 

https://knowledge.safe.com/articles/89369/getting-started-with-apis-1.html

 

And HTTPCaller transformer detailed here:

 

http://docs.safe.com/fme/2019.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/httpcaller.htm

Hope these are helpful. If you run into any issues, please don't hesitate to ask the community again.


  • Author
  • April 18, 2019
xiaomengatsafe wrote:

Hi @abeklaas, Welcome to FME Community Forum! Thanks for posting your first question!

It looks like GeoServer has an API, which makes me think we can use FME's HTTPCaller to upload files. Here is the documentation on their API, https://docs.geoserver.org/stable/en/user/rest/. Once you are familiar with the API, and find the appropriate endpoint for uploading files, FME can definitely help.

We have an article that might give you an overall introduction to API and how FME works with them:

 

https://knowledge.safe.com/articles/89369/getting-started-with-apis-1.html

 

And HTTPCaller transformer detailed here:

 

http://docs.safe.com/fme/2019.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/httpcaller.htm

Hope these are helpful. If you run into any issues, please don't hesitate to ask the community again.

Thanks xiaomeng,

I had a look at those. Indeed I am struggling a bit, especially with the "Upload Body". At the moment I am a step further. On https://gis.stackexchange.com/questions/244029/creating-workspace-data-store-and-layer-via-geoserver-rest-api I saw an example of a body to create a geoserver workspace (first step to do) and that worked. So no I can have a look of creating a datastore e..g. upload a shape into this workspace.

 


xiaomengatsafe
Safer
Forum|alt.badge.img+3
abeklaas wrote:

Thanks xiaomeng,

I had a look at those. Indeed I am struggling a bit, especially with the "Upload Body". At the moment I am a step further. On https://gis.stackexchange.com/questions/244029/creating-workspace-data-store-and-layer-via-geoserver-rest-api I saw an example of a body to create a geoserver workspace (first step to do) and that worked. So no I can have a look of creating a datastore e..g. upload a shape into this workspace.

 

Hi @abeklaas. If you already have the files you want to upload, in HTTPCaller, you can change the "Upload Data" parameter to "Upload from File", and then you can select the file you want to upload, directly in the "Upload File" parameter.

 

Hope this addresses the issue you are struggling with.

  • Author
  • April 25, 2019
xiaomengatsafe wrote:

Hi @abeklaas. If you already have the files you want to upload, in HTTPCaller, you can change the "Upload Data" parameter to "Upload from File", and then you can select the file you want to upload, directly in the "Upload File" parameter.

 

Hope this addresses the issue you are struggling with.

Hi @xiaomengatsafe. I tried the option "Upload from File" en selected a shapefile, but it didn't work. It is not allowed or the given URL is incorrect. I don't know the exact reason. With the option "Upload Data" I still have no success.


xiaomengatsafe
Safer
Forum|alt.badge.img+3
abeklaas wrote:

Hi @xiaomengatsafe. I tried the option "Upload from File" en selected a shapefile, but it didn't work. It is not allowed or the given URL is incorrect. I don't know the exact reason. With the option "Upload Data" I still have no success.

What HTTP method did you use (looking at their API documentation, POST is not valid, PUT should be used to upload file to datastore)? And what was the behaviour you saw, when you tried? Were there errors in the log? Did the HTTPCaller reject the feature?

This information may help us figure out what's the cause of the problem.


  • Author
  • April 26, 2019
xiaomengatsafe wrote:

What HTTP method did you use (looking at their API documentation, POST is not valid, PUT should be used to upload file to datastore)? And what was the behaviour you saw, when you tried? Were there errors in the log? Did the HTTPCaller reject the feature?

This information may help us figure out what's the cause of the problem.

I use PUT (although the geoserver documentation is a bit confusing at this point). At the moment I got a http 500 error. Because of that I changed this in the geoserver: "Access your geoserver web interface ( http://localhost:8070/geoserver/web ), ans then:Authentication --> Filter Chains --> rest --> Check HTTP Method (check), PUT (check) --> hit 'close' and then 'save'". But it didn't help

request URL = ......./geoserver/rest/workspaces/TEST

HTTP Method = PUT

Speficy Upload Body =

{

 

"dataStore": {

 

"name": "Shapefile1",

 

"connectionParameters": {

 

"entry": [

 

{"@key":"url","$":"file:data/TESTAKDJ/Shapefile1.shp"}

 

]

 

}

 

}

 

}

 

CONTENT TYPE = JSON (application/json)

Maybe it is a combination between creating datastore and access to the shapefile. The shapefile is already on the server.

If I try the method to Upload From File I also got a http 500 error.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings