如何通过 Node.js 将 .tif 文件上传到正在运行的 GeoServer?我想上传一个 GeoTIFF 以由 GeoServer 将其作为 WMS 提供。
GeoServer 以 405 响应,我认为这是正确的(http://docs.geoserver.org/latest/en/user/rest/api/coveragestores.html#workspaces-ws-coveragestores-cs-file-extension) . 不幸的是,我在 GeoServer 上找不到该文件。
这是我的代码:
// 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();