-1

How do I upload a .tif file to my running GeoServer via Node.js? I'd like to upload a GeoTIFF to provide it as a WMS by the GeoServer.

The GeoServer is responding with a 405, which I think is right (http://docs.geoserver.org/latest/en/user/rest/api/coveragestores.html#workspaces-ws-coveragestores-cs-file-extension). Unfortunately, I can't find the file on the GeoServer.

This is my code:

// GeoServer upload

var http = require('http'); 
var auth = 'Basic ' + new Buffer('admin' + ':' + 'geoserver').toString('base64');
//build the object to post
var post_data = (path.join(paperpath, paperid, "geotiff", req.files["otherfiles"][fileno].originalname)); // Path to .tif file

var s = JSON.stringify(post_data);
var post_options = {
  host: 'localhost',
  port: '9000',
  path: '/geoserver/rest/workspaces/myWorkspace/coveragestores/test/file',
  method: 'POST',
  headers: {
    'Content-Length': s.length,
    'Content-Type': 'image/tif',
    'Authorization': auth
  }
}
  // Set up the request
var post_req = http.request(post_options, function(res) {
  res.setEncoding('utf8');
  console.log(res.statusCode);

  res.on('data', function(chunk) {
    console.log('Success! ' + chunk);
  });
});
// post the data
post_req.write(s);
post_req.end();
Felix
  • 113
  • 1
  • 9

1 Answers1

0

I think first you need to upload the file within a folder that is accesible from geoserver (better in a folder of the geoserver data directory) and then use the rest api to configure the coverage store. Check this blog post it should give you a boost

pavlos
  • 3,001
  • 18
  • 23