mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Uploading now works everywhere. Show an flash message if the download fails.
This commit is contained in:
parent
27a001b1d2
commit
9385d28e40
3 changed files with 47 additions and 5 deletions
|
@ -34,6 +34,7 @@ namespace App\Controller\AdminPages;
|
|||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Exceptions\AttachmentDownloadException;
|
||||
use App\Form\AdminPages\ImportType;
|
||||
use App\Form\AdminPages\MassCreationForm;
|
||||
use App\Services\AttachmentHelper;
|
||||
|
@ -109,7 +110,14 @@ abstract class BaseAdminController extends AbstractController
|
|||
'secure_attachment' => $attachment['secureFile']->getData(),
|
||||
'download_url' => $attachment['downloadURL']->getData()
|
||||
];
|
||||
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||
try {
|
||||
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||
} catch (AttachmentDownloadException $ex) {
|
||||
$this->addFlash(
|
||||
'error',
|
||||
$this->translator->trans('attachment.download_failed') . ' ' . $ex->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$em->persist($entity);
|
||||
|
@ -154,7 +162,18 @@ abstract class BaseAdminController extends AbstractController
|
|||
$attachments = $form['attachments'];
|
||||
foreach ($attachments as $attachment) {
|
||||
/** @var $attachment FormInterface */
|
||||
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData());
|
||||
$options = [
|
||||
'secure_attachment' => $attachment['secureFile']->getData(),
|
||||
'download_url' => $attachment['downloadURL']->getData()
|
||||
];
|
||||
try {
|
||||
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||
} catch (AttachmentDownloadException $ex) {
|
||||
$this->addFlash(
|
||||
'error',
|
||||
$this->translator->trans('attachment.download_failed') . ' ' . $ex->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$em->persist($new_entity);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue