Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/passman.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js/app
diff options
context:
space:
mode:
authorbinsky <timo@binsky.org>2021-03-24 19:41:49 +0300
committerbinsky <timo@binsky.org>2021-03-24 19:41:49 +0300
commit3cbb2dcda1dd0f9f042ad38199fc6c6e4264e5b4 (patch)
tree588c59dbb3f6a7173cc59ae0973ec124b3a83c96 /js/app
parent3e13fa6d391fb1ed703f1a047c614ed44e29f63a (diff)
add files support to the generic csv importer
Diffstat (limited to 'js/app')
-rw-r--r--js/app/controllers/generic-csv-importer.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/js/app/controllers/generic-csv-importer.js b/js/app/controllers/generic-csv-importer.js
index 59185b30..4117eae3 100644
--- a/js/app/controllers/generic-csv-importer.js
+++ b/js/app/controllers/generic-csv-importer.js
@@ -67,6 +67,11 @@
matching: ['custom_fields', 'customFields']
},
{
+ label: 'Files',
+ prop: 'files',
+ matching: ['files']
+ },
+ {
label: 'Notes',
prop: 'description',
matching: ['notes', 'description', 'comments']
@@ -114,7 +119,6 @@
for(var i = 0; k < row[k].length; i++){
_credential.custom_fields.push({
'label': row[k][i].label,
- 'value': row[k][i].value,
'secret': row[k][i].secret,
'field_type': row[k][i].field_type,
});
@@ -142,6 +146,35 @@
_credential.custom_fields.push(row[k][j]);
}
}
+ } else if(field === 'files'){
+ if (row[k] !== undefined && (typeof row[k] === 'string' || row[k] instanceof String) && row[k].length > 1){
+ try {
+ row[k] = JSON.parse(row[k]);
+ for(var i = 0; k < row[k].length; i++){
+ _credential.files.push({
+ filename: row[k][i].filename,
+ size: row[k][i].size,
+ mimetype: row[k][i].mimetype
+ });
+ }
+ } catch (e) {
+ // ignore row[k], it contains no valid json data
+ // console.error(e);
+ }
+ } else {
+ for(var j = 0; j < row[k].length; j++){
+ _credential.files.push(await FileService.uploadFile({
+ filename: row[k][j].filename,
+ size: row[k][j].size,
+ mimetype: row[k][j].mimetype,
+ data: row[k][j].file_data
+ }).then(function (result) {
+ delete result.file_data;
+ result.filename = EncryptService.decryptString(result.filename);
+ return result;
+ }));
+ }
+ }
} else if(field === 'tags'){
if( row[k]) {
var tags = row[k].split(',');