diff --git a/app/controllers/api/v1/Export.controller.js b/app/controllers/api/v1/Export.controller.js index 355e5ec..ece5f21 100644 --- a/app/controllers/api/v1/Export.controller.js +++ b/app/controllers/api/v1/Export.controller.js @@ -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(`