mirror of
https://github.com/sismics/docs.git
synced 2024-11-21 21:47:57 +01:00
#210: create documents with file importer
This commit is contained in:
parent
7aa4a1bf82
commit
dc8b8ae6c4
@ -228,9 +228,23 @@ const importFile = (file, remove, resolve) => {
|
|||||||
spinner: 'flips'
|
spinner: 'flips'
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
|
request.put({
|
||||||
|
url: prefs.importer.baseUrl + '/api/document',
|
||||||
|
form: {
|
||||||
|
title: file.replace(/^.*[\\\/]/, ''),
|
||||||
|
language: 'eng'
|
||||||
|
}
|
||||||
|
}, function (error, response, body) {
|
||||||
|
if (error || !response || response.statusCode !== 200) {
|
||||||
|
spinner.fail('Upload failed for ' + file + ': ' + error);
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
request.put({
|
request.put({
|
||||||
url: prefs.importer.baseUrl + '/api/file',
|
url: prefs.importer.baseUrl + '/api/file',
|
||||||
formData: {
|
formData: {
|
||||||
|
id: JSON.parse(body).id,
|
||||||
file: fs.createReadStream(file)
|
file: fs.createReadStream(file)
|
||||||
}
|
}
|
||||||
}, function (error, response) {
|
}, function (error, response) {
|
||||||
@ -245,6 +259,7 @@ const importFile = (file, remove, resolve) => {
|
|||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Entrypoint: daemon mode or wizard
|
// Entrypoint: daemon mode or wizard
|
||||||
|
Loading…
Reference in New Issue
Block a user