mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
use formdata to pass text arguments during import instead of request path
This commit is contained in:
parent
886ea6c68c
commit
d8ba0ccd7d
@ -50,15 +50,17 @@ async function importIntoNote(importNoteId) {
|
|||||||
// dialog (which shouldn't happen, but still ...)
|
// dialog (which shouldn't happen, but still ...)
|
||||||
importId = utils.randomString(10);
|
importId = utils.randomString(10);
|
||||||
|
|
||||||
const safeImport = $safeImport.is(":checked") ? 1 : 0;
|
const safeImport = $safeImport.is(":checked") ? "true" : "false";
|
||||||
let noteId;
|
let noteId;
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('upload', file);
|
formData.append('upload', file);
|
||||||
|
formData.append('importId', importId);
|
||||||
|
formData.append('safeImport', safeImport);
|
||||||
|
|
||||||
noteId = await $.ajax({
|
({noteId} = await $.ajax({
|
||||||
url: baseApiUrl + 'notes/' + importNoteId + '/import/' + importId + '/safe/' + safeImport,
|
url: baseApiUrl + 'notes/' + importNoteId + '/import',
|
||||||
headers: server.getHeaders(),
|
headers: server.getHeaders(),
|
||||||
data: formData,
|
data: formData,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
@ -68,7 +70,7 @@ async function importIntoNote(importNoteId) {
|
|||||||
processData: false, // NEEDED, DON'T REMOVE THIS
|
processData: false, // NEEDED, DON'T REMOVE THIS
|
||||||
})
|
})
|
||||||
// we actually ignore the error since it can be caused by HTTP timeout and use WS messages instead.
|
// we actually ignore the error since it can be caused by HTTP timeout and use WS messages instead.
|
||||||
.fail((xhr, status, error) => {});
|
.fail((xhr, status, error) => {}));
|
||||||
}
|
}
|
||||||
|
|
||||||
$dialog.modal('hide');
|
$dialog.modal('hide');
|
||||||
|
@ -12,9 +12,10 @@ const log = require('../../services/log');
|
|||||||
const ImportContext = require('../../services/import_context');
|
const ImportContext = require('../../services/import_context');
|
||||||
|
|
||||||
async function importToBranch(req) {
|
async function importToBranch(req) {
|
||||||
let {parentNoteId, importId, safeImport} = req.params;
|
const {parentNoteId} = req.params;
|
||||||
|
let {importId, safeImport} = req.body;
|
||||||
|
|
||||||
safeImport = safeImport !== '0';
|
safeImport = safeImport !== 'false';
|
||||||
|
|
||||||
const file = req.file;
|
const file = req.file;
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ function register(app) {
|
|||||||
apiRoute(PUT, '/api/notes/:noteId/clone-after/:afterBranchId', cloningApiRoute.cloneNoteAfter);
|
apiRoute(PUT, '/api/notes/:noteId/clone-after/:afterBranchId', cloningApiRoute.cloneNoteAfter);
|
||||||
|
|
||||||
route(GET, '/api/notes/:branchId/export/:type/:format/:version/:exportId', [auth.checkApiAuthOrElectron], exportRoute.exportBranch);
|
route(GET, '/api/notes/:branchId/export/:type/:format/:version/:exportId', [auth.checkApiAuthOrElectron], exportRoute.exportBranch);
|
||||||
route(POST, '/api/notes/:parentNoteId/import/:importId/safe/:safeImport', [auth.checkApiAuthOrElectron, uploadMiddleware], importRoute.importToBranch, apiResultHandler);
|
route(POST, '/api/notes/:parentNoteId/import', [auth.checkApiAuthOrElectron, uploadMiddleware], importRoute.importToBranch, apiResultHandler);
|
||||||
|
|
||||||
route(POST, '/api/notes/:parentNoteId/upload', [auth.checkApiAuthOrElectron, uploadMiddleware],
|
route(POST, '/api/notes/:parentNoteId/upload', [auth.checkApiAuthOrElectron, uploadMiddleware],
|
||||||
filesRoute.uploadFile, apiResultHandler);
|
filesRoute.uploadFile, apiResultHandler);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user