refactor all media create to centralise copy of medias and save, etc.

This commit is contained in:
osaajani 2021-03-26 23:32:29 +01:00
parent 92146ba8e1
commit 04a40049ce
18 changed files with 400 additions and 367 deletions

View file

@ -362,12 +362,15 @@ namespace controllers\publics;
{
foreach ($files_arrays as $file)
{
$new_media_id = $this->internal_media->upload_and_create_for_user($this->user['id'], $file);
if (!$new_media_id)
try
{
$new_media_id = $this->internal_media->upload_and_create_for_user($this->user['id'], $file);
}
catch (\Exception $e)
{
$return = self::DEFAULT_RETURN;
$return['error'] = self::ERROR_CODES['CANNOT_CREATE'];
$return['message'] = self::ERROR_MESSAGES['CANNOT_CREATE'] . ' : Cannot upload and create media file ' . $file['name'];
$return['message'] = self::ERROR_MESSAGES['CANNOT_CREATE'] . ' : Cannot upload and create media file ' . $file['name'] . ' : ' . $e->getMessage();
$this->auto_http_code(false);
return $this->json($return);