Noded/frontend#29 - allow uploading multiple files at once
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Garrett Mills 2021-02-02 08:24:01 -06:00
parent 2c105fe350
commit a59255a39b
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

View File

@ -49,13 +49,17 @@ class File extends Controller {
async save_upload(req, res) {
const { page, node, file_group } = req.form
let file_name = ''
if ( req.uploads.uploaded_file ) {
file_group.FileIds.push(req.uploads.uploaded_file.id)
const n_files = Object.values(req.uploads).length
for ( const key in req.uploads ) {
if ( !req.uploads.hasOwnProperty(key) ) continue
if ( !key.startsWith('uploaded_file_') ) continue
file_group.FileIds.push(req.uploads[key].id)
}
await file_group.version_save(`Added file${file_name ? ' "'+file_name+'"' : ''}`, req.user.id)
return res.redirect(req.body.redirectTo ? req.body.redirectTo : '/')
await file_group.version_save(`Added ${n_files} file${n_files === 1 ? '' : 's'}`, req.user.id)
return res.api()
}
async download(req, res) {