Fix export controller to be upload-provider agnostic
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user