Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to add external GPKG #81

Open
JakobMiksch opened this issue May 18, 2022 · 0 comments
Open

Add function to add external GPKG #81

JakobMiksch opened this issue May 18, 2022 · 0 comments

Comments

@JakobMiksch
Copy link
Contributor

JakobMiksch commented May 18, 2022

GeoTIFFs can currently added when they are located externally of the GeoServer data directory.

async createGeotiffFromFile (workspace, coverageStore, layerName, layerTitle, filePath) {
const lyrTitle = layerTitle || layerName;
const stats = fs.statSync(filePath);
const fileSizeInBytes = stats.size;
const readStream = fs.createReadStream(filePath);
let url = this.url + 'workspaces/' + workspace + '/coveragestores/' +
coverageStore + '/file.geotiff';
url += '?filename=' + lyrTitle + '&coverageName=' + layerName;
const response = await fetch(url, {
credentials: 'include',
method: 'PUT',
headers: {
Authorization: this.auth,
'Content-Type': 'image/tiff',
'Content-length': fileSizeInBytes
},
body: readStream
});
if (!response.ok) {
const geoServerResponse = await getGeoServerResponseText(response);
throw new GeoServerResponseError(null, geoServerResponse);
}
// TODO: enforce JSON response or parse XML
return response.text();
}

However, this feature is possible with GPKG as well, but is not implemented.

Basic functionality is:

curl \
  -u admin:geoserver \
  -T /path/to/world.gpkg \
  "http://localhost:8080/geoserver/rest/workspaces/klips/datastores/foobar/file.gpkg"

curl \
  -u admin:geoserver \
  -H "Content-type: application/zip" \
  -T /path/to/world.shp.zip \
  "http://localhost:8080/geoserver/rest/workspaces/klips/datastores/foobar/file.shp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant