Fix export controller to be upload-provider agnostic
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
2020-11-29 02:41:45 -06:00
parent 97b4bf662c
commit f935507612
3 changed files with 15 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ const path = require('path')
const md = require('markdown').markdown
const rimraf = require('rimraf')
const uuid = require('uuid/v4')
const tmp = require('tmp-promise')
class ExportController extends Controller {
static get services() {
@@ -214,9 +215,11 @@ class ExportController extends Controller {
for ( const file_id of file_group.FileIds ) {
const file = await File.findById(file_id)
if ( file ) {
const store_path = file.provider().filepath(file.store_id)
const tmp_file = await tmp.file()
await file.provider().download_file(file, tmp_file.path)
const ext = file.original_name.split('.').reverse()[0]
await this.copy_template(store_path, path.resolve(work_dir, `file-${file.upload_name}.${ext}`))
await this.copy_template(tmp_file.path, path.resolve(work_dir, `file-${file.upload_name}.${ext}`))
await fs.unlink(tmp_file.path)
file_htmls.push(`
<div class="file">