kopia lustrzana https://github.com/OpenDroneMap/NodeODM
Added set-uuid parameter in headers for /task/new
rodzic
e4e6054aca
commit
2b76079bbd
|
@ -8,7 +8,7 @@ REST API to access ODM
|
||||||
|
|
||||||
=== Version information
|
=== Version information
|
||||||
[%hardbreaks]
|
[%hardbreaks]
|
||||||
_Version_ : 1.2.1
|
_Version_ : 1.2.2
|
||||||
|
|
||||||
|
|
||||||
=== Contact information
|
=== Contact information
|
||||||
|
@ -167,16 +167,18 @@ Creates a new task and places it at the end of the processing queue
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
||||||
|===
|
|===
|
||||||
|Type|Name|Description|Schema|Default
|
|Type|Name|Description|Schema|Default
|
||||||
|
|*Header*|*set-uuid* +
|
||||||
|
_optional_|An optional UUID string that will be used as UUID for this task instead of generating a random one.|string|
|
||||||
|*Query*|*token* +
|
|*Query*|*token* +
|
||||||
_optional_|Token required for authentication (when authentication is required).|string|
|
_optional_|Token required for authentication (when authentication is required).|string|
|
||||||
|*FormData*|*images* +
|
|*FormData*|*images* +
|
||||||
_optional_|Images to process, plus an optional GPC file. If included, the GPC file should have .txt extension|file|
|
_optional_|Images to process, plus an optional GCP file. If included, the GCP file should have .txt extension|file|
|
||||||
|*FormData*|*name* +
|
|*FormData*|*name* +
|
||||||
_optional_|An optional name to be associated with the task|string|
|
_optional_|An optional name to be associated with the task|string|
|
||||||
|*FormData*|*options* +
|
|*FormData*|*options* +
|
||||||
_optional_|Serialized JSON string of the options to use for processing, as an array of the format: [{name: option1, value: value1}, {name: option2, value: value2}, …]. For example, [{"name":"cmvs-maxImages","value":"500"},{"name":"time","value":true}]. For a list of all options, call /options|string|
|
_optional_|Serialized JSON string of the options to use for processing, as an array of the format: [{name: option1, value: value1}, {name: option2, value: value2}, …]. For example, [{"name":"cmvs-maxImages","value":"500"},{"name":"time","value":true}]. For a list of all options, call /options|string|
|
||||||
|*FormData*|*zipurl* +
|
|*FormData*|*zipurl* +
|
||||||
_optional_|URL of the zip file containing the images to process, plus an optional GPC file. If included, the GPC file should have .txt extension|string|
|
_optional_|URL of the zip file containing the images to process, plus an optional GCP file. If included, the GCP file should have .txt extension|string|
|
||||||
|===
|
|===
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
76
index.js
76
index.js
|
@ -17,35 +17,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
let fs = require('fs');
|
const fs = require('fs');
|
||||||
let config = require('./config.js');
|
const config = require('./config.js');
|
||||||
let packageJson = JSON.parse(fs.readFileSync('./package.json'));
|
const packageJson = JSON.parse(fs.readFileSync('./package.json'));
|
||||||
|
|
||||||
let logger = require('./libs/logger');
|
const logger = require('./libs/logger');
|
||||||
let path = require('path');
|
const path = require('path');
|
||||||
let async = require('async');
|
const async = require('async');
|
||||||
let mime = require('mime');
|
const mime = require('mime');
|
||||||
let rmdir = require('rimraf');
|
const rmdir = require('rimraf');
|
||||||
|
|
||||||
let express = require('express');
|
const express = require('express');
|
||||||
let app = express();
|
const app = express();
|
||||||
|
|
||||||
let addRequestId = require('./libs/expressRequestId')();
|
const multer = require('multer');
|
||||||
let multer = require('multer');
|
const bodyParser = require('body-parser');
|
||||||
let bodyParser = require('body-parser');
|
const morgan = require('morgan');
|
||||||
let morgan = require('morgan');
|
|
||||||
|
|
||||||
let TaskManager = require('./libs/TaskManager');
|
const TaskManager = require('./libs/TaskManager');
|
||||||
let Task = require('./libs/Task');
|
const Task = require('./libs/Task');
|
||||||
let odmInfo = require('./libs/odmInfo');
|
const odmInfo = require('./libs/odmInfo');
|
||||||
let Directories = require('./libs/Directories');
|
const Directories = require('./libs/Directories');
|
||||||
let unzip = require('node-unzip-2');
|
const unzip = require('node-unzip-2');
|
||||||
let si = require('systeminformation');
|
const si = require('systeminformation');
|
||||||
let mv = require('mv');
|
const mv = require('mv');
|
||||||
let S3 = require('./libs/S3');
|
const S3 = require('./libs/S3');
|
||||||
|
|
||||||
let auth = require('./libs/auth/factory').fromConfig(config);
|
const auth = require('./libs/auth/factory').fromConfig(config);
|
||||||
const authCheck = auth.getMiddleware();
|
const authCheck = auth.getMiddleware();
|
||||||
|
const uuidv4 = require('uuid/v4');
|
||||||
|
|
||||||
|
|
||||||
// zip files
|
// zip files
|
||||||
let request = require('request');
|
let request = require('request');
|
||||||
|
@ -106,13 +107,13 @@ let server;
|
||||||
* -
|
* -
|
||||||
* name: images
|
* name: images
|
||||||
* in: formData
|
* in: formData
|
||||||
* description: Images to process, plus an optional GPC file. If included, the GPC file should have .txt extension
|
* description: Images to process, plus an optional GCP file. If included, the GCP file should have .txt extension
|
||||||
* required: false
|
* required: false
|
||||||
* type: file
|
* type: file
|
||||||
* -
|
* -
|
||||||
* name: zipurl
|
* name: zipurl
|
||||||
* in: formData
|
* in: formData
|
||||||
* description: URL of the zip file containing the images to process, plus an optional GPC file. If included, the GPC file should have .txt extension
|
* description: URL of the zip file containing the images to process, plus an optional GCP file. If included, the GCP file should have .txt extension
|
||||||
* required: false
|
* required: false
|
||||||
* type: string
|
* type: string
|
||||||
* -
|
* -
|
||||||
|
@ -133,6 +134,12 @@ let server;
|
||||||
* description: 'Token required for authentication (when authentication is required).'
|
* description: 'Token required for authentication (when authentication is required).'
|
||||||
* required: false
|
* required: false
|
||||||
* type: string
|
* type: string
|
||||||
|
* -
|
||||||
|
* name: set-uuid
|
||||||
|
* in: header
|
||||||
|
* description: 'An optional UUID string that will be used as UUID for this task instead of generating a random one.'
|
||||||
|
* required: false
|
||||||
|
* type: string
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Success
|
* description: Success
|
||||||
|
@ -148,7 +155,24 @@ let server;
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: '#/definitions/Error'
|
* $ref: '#/definitions/Error'
|
||||||
*/
|
*/
|
||||||
app.post('/task/new', authCheck, addRequestId, upload.array('images'), (req, res) => {
|
app.post('/task/new', authCheck, (req, res, next) => {
|
||||||
|
// A user can optionally suggest a UUID instead of letting
|
||||||
|
// nodeODM pick one.
|
||||||
|
if (req.get('set-uuid')){
|
||||||
|
const userUuid = req.get('set-uuid');
|
||||||
|
|
||||||
|
// Valid UUID and no other task with same UUID?
|
||||||
|
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(userUuid) && !taskManager.find(userUuid)){
|
||||||
|
req.id = userUuid;
|
||||||
|
next();
|
||||||
|
}else{
|
||||||
|
res.json({error: `Invalid set-uuid: ${userUuid}`})
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
req.id = uuidv4();
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}, upload.array('images'), (req, res) => {
|
||||||
let srcPath = path.join("tmp", req.id);
|
let srcPath = path.join("tmp", req.id);
|
||||||
|
|
||||||
// Print error message and cleanup
|
// Print error message and cleanup
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
let uuid = require('node-uuid');
|
|
||||||
|
|
||||||
module.exports = function (options) {
|
|
||||||
options = options || {};
|
|
||||||
options.uuidVersion = options.uuidVersion || 'v4';
|
|
||||||
options.setHeader = options.setHeader === undefined || !!options.setHeader;
|
|
||||||
|
|
||||||
return function (req, res, next) {
|
|
||||||
req.id = uuid[options.uuidVersion](options, options.buffer, options.offset);
|
|
||||||
if (options.setHeader) {
|
|
||||||
res.setHeader('X-Request-Id', req.id);
|
|
||||||
}
|
|
||||||
next();
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "node-opendronemap",
|
"name": "node-opendronemap",
|
||||||
"version": "1.2.1",
|
"version": "1.2.2",
|
||||||
"description": "REST API to access ODM",
|
"description": "REST API to access ODM",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -33,12 +33,12 @@
|
||||||
"mv": "^2.1.1",
|
"mv": "^2.1.1",
|
||||||
"node-schedule": "^1.1.1",
|
"node-schedule": "^1.1.1",
|
||||||
"node-unzip-2": "^0.2.7",
|
"node-unzip-2": "^0.2.7",
|
||||||
"node-uuid": "^1.4.7",
|
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
"rimraf": "^2.5.3",
|
"rimraf": "^2.5.3",
|
||||||
"swagger-jsdoc": "^1.3.1",
|
"swagger-jsdoc": "^1.3.1",
|
||||||
"systeminformation": "^3.42.0",
|
"systeminformation": "^3.42.0",
|
||||||
"tree-kill": "^1.1.0",
|
"tree-kill": "^1.1.0",
|
||||||
|
"uuid": "^3.3.2",
|
||||||
"winston": "^2.2.0"
|
"winston": "^2.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -286,6 +286,7 @@ $(function() {
|
||||||
elErrorContainer: '#errorBlock',
|
elErrorContainer: '#errorBlock',
|
||||||
showUpload: false,
|
showUpload: false,
|
||||||
uploadAsync: false,
|
uploadAsync: false,
|
||||||
|
// ajaxSettings: { headers: { 'set-uuid': '8366b2ad-a608-4cd1-bdcb-c3d84a034623' } },
|
||||||
uploadExtraData: function() {
|
uploadExtraData: function() {
|
||||||
return {
|
return {
|
||||||
name: $("#taskName").val(),
|
name: $("#taskName").val(),
|
||||||
|
|
Ładowanie…
Reference in New Issue