mirror of
https://github.com/nextcloud/passman.git
synced 2026-02-22 02:08:08 +08:00
add files support to the generic csv importer
This commit is contained in:
parent
3e13fa6d39
commit
3cbb2dcda1
1 changed files with 34 additions and 1 deletions
|
|
@ -66,6 +66,11 @@
|
|||
prop: 'custom_fields',
|
||||
matching: ['custom_fields', 'customFields']
|
||||
},
|
||||
{
|
||||
label: 'Files',
|
||||
prop: 'files',
|
||||
matching: ['files']
|
||||
},
|
||||
{
|
||||
label: 'Notes',
|
||||
prop: 'description',
|
||||
|
|
@ -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(',');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue