Fix archive download via API

This commit is contained in:
Thibaud Fabre
2016-05-23 17:54:40 +02:00
parent 9c287e0cd9
commit cf684cdeca
3 changed files with 12 additions and 5 deletions

View File

@@ -162,7 +162,7 @@ class DoDownloadController extends Controller
$this->app, $this->app,
$token, $token,
$list, $list,
sprintf($this->app['tmp.download.path'].'/%s.zip', $token->getValue()) // Dest file sprintf('%s/%s.zip', $this->app['tmp.download.path'], $token->getValue()) // Dest file
); );
} else { } else {
$list['complete'] = true; $list['complete'] = true;

View File

@@ -1,4 +1,5 @@
<?php <?php
/* /*
* This file is part of Phraseanet * This file is part of Phraseanet
* *
@@ -7,6 +8,7 @@
* For the full copyright and license information, please view the LICENSE * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Databox; namespace Alchemy\Phrasea\Databox;
interface DataboxRepository interface DataboxRepository

View File

@@ -157,7 +157,7 @@ class ApiOrderController extends BaseOrderController
} }
$export = new \set_export($this->app, '', $basket->getId()); $export = new \set_export($this->app, '', $basket->getId());
$exportName = sprintf('%s.zip', $export->getExportName()); $exportName = sprintf('%s/%s.zip', $this->app['tmp.download.path'], $export->getExportName());
$user = $this->getAuthenticatedUser(); $user = $this->getAuthenticatedUser();
@@ -167,10 +167,15 @@ class ApiOrderController extends BaseOrderController
$exportData['export_name'] = $exportName; $exportData['export_name'] = $exportName;
$token = $this->app['manipulator.token']->createDownloadToken($user, serialize($exportData)); $token = $this->app['manipulator.token']->createDownloadToken($user, serialize($exportData));
$lst = [];
foreach ($exportData['files'] as $file) {
$lst[] = $this->getApplicationBox()->get_collection($file['base_id'])->get_databox()->get_sbas_id() . '_' . $file['record_id'];
}
$this->dispatch( $this->dispatch(
PhraseaEvents::EXPORT_CREATE, PhraseaEvents::EXPORT_CREATE,
new ExportEvent($user, $basket->getId(), '', $subdefs, $exportName) new ExportEvent($user, $basket->getId(), implode(';', $lst), $subdefs, $exportName)
); );
set_time_limit(0); set_time_limit(0);
@@ -330,7 +335,7 @@ class ApiOrderController extends BaseOrderController
$subdefNames = [ $subdefNames = [
'document' => true, 'document' => true,
]; ];
$this->getApplicationBox()->get_collection($file['base_id'])->get_databox()->get_sbas_id();
foreach ($this->getApplicationBox()->get_databoxes() as $databox) { foreach ($this->getApplicationBox()->get_databoxes() as $databox) {
foreach ($databox->get_subdef_structure() as $subdefGroup) { foreach ($databox->get_subdef_structure() as $subdefGroup) {
/** @var \databox_subdef $subdef */ /** @var \databox_subdef $subdef */