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/Geosoftware-2/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.on('data', function(chunk) {
        console.log('Success! ' + chunk);
    // post the data
  • 1
    You should just be able to build a http.request, put the data in (per the REST API - docs.geoserver.org/stable/en/user/rest/api), and call write() and end() on the request. What have you tried, and what were the results? Can you show a minimal, complete example? – BradHards Dec 9 '15 at 19:58
  • I edited my post so you can see the code – Felix Dec 14 '15 at 6:42
  • @Felix - did you ever figure this out? – jotamon Apr 19 '18 at 16:13
  • @jotamon Unfortunately not... – Felix May 30 '18 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.