Fix export controller to be upload-provider agnostic
This commit is contained in:
parent
97b4bf662c
commit
f935507612
@ -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">
|
||||
|
@ -32,6 +32,7 @@
|
||||
"rimraf": "^3.0.2",
|
||||
"tar": "^6.0.5",
|
||||
"tempfile": "^3.0.0",
|
||||
"tmp": "^0.2.1"
|
||||
"tmp": "^0.2.1",
|
||||
"tmp-promise": "^3.0.2"
|
||||
}
|
||||
}
|
||||
|
@ -4253,7 +4253,14 @@ through@~2.3.8:
|
||||
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
|
||||
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
|
||||
|
||||
tmp@^0.2.1:
|
||||
tmp-promise@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/tmp-promise/-/tmp-promise-3.0.2.tgz#6e933782abff8b00c3119d63589ca1fb9caaa62a"
|
||||
integrity sha512-OyCLAKU1HzBjL6Ev3gxUeraJNlbNingmi8IrHHEsYH8LTmEuhvYfqvhn2F/je+mjf4N58UmZ96OMEy1JanSCpA==
|
||||
dependencies:
|
||||
tmp "^0.2.0"
|
||||
|
||||
tmp@^0.2.0, tmp@^0.2.1:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14"
|
||||
integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==
|
||||
|
Loading…
Reference in New Issue
Block a user